Re: [Qemu-devel] buildbot failure in qemu on default_mingw32

2012-11-02 Thread Stefan Hajnoczi
On Sat, Nov 3, 2012 at 2:11 AM,   wrote:
> The Buildbot has detected a new failure on builder default_mingw32 while 
> building qemu.
> Full details are available at:
>  http://buildbot.b1-systems.de/qemu/builders/default_mingw32/builds/424

Hi Daniel,
The DNS for qemu.org is down.  Anthony Liguori registered an
alternative domain at git.qemu-project.org yesterday.

Please update the buildbot config to use git.qemu-project.org.  This
new domain name for QEMU will be permanent.

"fatal: Unable to look up git.qemu.org (port 9418) (Name or service not known)"

Thanks,
Stefan



[Qemu-devel] [PATCH] Add realtime option

2012-11-02 Thread Satoru Moriya
We have some plans to migrate old enterprise/control systems which
require low latency (msec order) to kvm virtualized environment.
In order to satisfy the requirements, this patch adds realtime option
to qemu:

 -realtime maxprio=,policy=

This option change the scheduling policy and priority to realtime one
(only vcpu thread) as specified with argument and mlock all qemu and
guest memory.

Of course, we need much more improvements to keep latency low in qemu
virtualized environment and this is a first step. OTOH, we can meet the
requirement of our first migration project with this patch.

These are basic performance test results:

Host : 4 core, 4GB, 3.7.0-rc3
Guest: 1 core, 512MB, 3.6.3-1.fc17

Benchmark: cyclictest
https://rt.wiki.kernel.org/index.php/Cyclictest

Command:
 $ cyclictest -p 99 -n -m -q -l 10

Results:
 - no load (1:normal qemu, 2:realtime qemu)
   1. T: 0 ( 544) P:99 I:1000 C:10 Min: 11 Act: 32 Avg: 157 Max: 10029
   2. T: 0 ( 449) P:99 I:1000 C:10 Min: 16 Act: 30 Avg:  29 Max:   540

 - load (heavy network traffic) (3:normal qemu, 4: realtime qemu)
   3. T: 0 (3455) P:99 I:1000 C:10 Min: 10 Act: 38 Avg: 364 Max: 18394
   4. T: 0 ( 493) P:99 I:1000 C:10 Min: 12 Act: 21 Avg:  76 Max: 10796

Signed-off-by: Satoru Moriya 
---
 cpus.c  | 10 ++
 cpus.h  |  3 +++
 qemu-config.c   | 16 
 qemu-options.hx |  9 +
 vl.c| 51 +++
 5 files changed, 89 insertions(+)

diff --git a/cpus.c b/cpus.c
index d9c332f..456e6ea 100644
--- a/cpus.c
+++ b/cpus.c
@@ -734,6 +734,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg)
 CPUArchState *env = arg;
 CPUState *cpu = ENV_GET_CPU(env);
 int r;
+struct sched_param sp;
 
 qemu_mutex_lock(&qemu_global_mutex);
 qemu_thread_get_self(cpu->thread);
@@ -746,6 +747,15 @@ static void *qemu_kvm_cpu_thread_fn(void *arg)
 exit(1);
 }
 
+if (realtime) {
+sp.sched_priority = realtime_prio;
+r = sched_setscheduler(0, realtime_pol, &sp);
+if (r < 0) {
+perror("Setting realtime policy failed");
+exit(1);
+}
+}
+
 qemu_kvm_init_cpu_signals(env);
 
 /* signal CPU creation */
diff --git a/cpus.h b/cpus.h
index 81bd817..a6b2688 100644
--- a/cpus.h
+++ b/cpus.h
@@ -16,6 +16,9 @@ void qtest_clock_warp(int64_t dest);
 /* vl.c */
 extern int smp_cores;
 extern int smp_threads;
+extern int realtime;
+extern int realtime_prio;
+extern int realtime_pol;
 void set_numa_modes(void);
 void set_cpu_log(const char *optarg);
 void set_cpu_log_filename(const char *optarg);
diff --git a/qemu-config.c b/qemu-config.c
index 3154cac..13290c6 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -658,6 +658,21 @@ QemuOptsList qemu_boot_opts = {
 .type = QEMU_OPT_STRING,
 },
 { /*End of list */ }
+},
+};
+
+QemuOptsList qemu_realtime_opts = {
+.name = "realtime",
+.head = QTAILQ_HEAD_INITIALIZER(qemu_realtime_opts.head),
+.desc = {
+{
+.name = "maxprio",
+.type = QEMU_OPT_NUMBER,
+}, {
+.name = "policy",
+.type = QEMU_OPT_STRING,
+},
+{ /* End of List */ }
 },
 };
 
@@ -699,6 +714,7 @@ static QemuOptsList *vm_config_groups[32] = {
 &qemu_iscsi_opts,
 &qemu_sandbox_opts,
 &qemu_add_fd_opts,
+&qemu_realtime_opts,
 NULL,
 };
 
diff --git a/qemu-options.hx b/qemu-options.hx
index fe8f15c..eb8ba05 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2405,6 +2405,15 @@ STEXI
 Do not start CPU at startup (you must type 'c' in the monitor).
 ETEXI
 
+DEF("realtime", HAS_ARG, QEMU_OPTION_realtime,
+"-realtime maxprio=prio[,policy=pol]\n",
+QEMU_ARCH_ALL)
+STEXI
+@item -realtime maxprio=@var{prio}[,policy=@var{pol}]
+@findex -realtime
+run qemu as a realtime process with priority @var{prio} and policy @var{pol}.
+ETEXI
+
 DEF("gdb", HAS_ARG, QEMU_OPTION_gdb, \
 "-gdb devwait for gdb connection on 'dev'\n", QEMU_ARCH_ALL)
 STEXI
diff --git a/vl.c b/vl.c
index 0f5b07b..a08fe79 100644
--- a/vl.c
+++ b/vl.c
@@ -248,6 +248,10 @@ int nb_numa_nodes;
 uint64_t node_mem[MAX_NODES];
 unsigned long *node_cpumask[MAX_NODES];
 
+int realtime;
+int realtime_prio;
+int realtime_pol;
+
 uint8_t qemu_uuid[16];
 
 static QEMUBootSetHandler *boot_set_handler;
@@ -1151,6 +1155,45 @@ static void smp_parse(const char *optarg)
 max_cpus = smp_cpus;
 }
 
+static void configure_realtime(QemuOpts *opts) {
+int prio, max_prio, min_prio;
+const char *pol;
+
+pol = qemu_opt_get(opts, "policy");
+if (pol) {
+if (!strcmp(pol, "rr")) {
+realtime_pol = SCHED_RR;
+} else if (!strcmp(pol, "fifo")) {
+realtime_pol = SCHED_FIFO;
+} else {
+fprintf(stderr, "qemu: invalid option value '%s'\n", pol);
+exit(1);
+}
+} else {
+realtime_pol = SCHED

[Qemu-devel] buildbot failure in qemu on default_mingw32

2012-11-02 Thread qemu
The Buildbot has detected a new failure on builder default_mingw32 while 
building qemu.
Full details are available at:
 http://buildbot.b1-systems.de/qemu/builders/default_mingw32/builds/424

Buildbot URL: http://buildbot.b1-systems.de/qemu/

Buildslave for this Build: kraxel_rhel61

Build Reason: The Nightly scheduler named 'nightly_default' triggered this build
Build Source Stamp: [branch master] HEAD
Blamelist: 

BUILD FAILED: failed git

sincerely,
 -The Buildbot



Re: [Qemu-devel] [PATCHv2 3/4] Support for "double whitelist" filters

2012-11-02 Thread Paul Moore
On Friday, November 02, 2012 06:00:29 PM Corey Bryant wrote:
> On 11/02/2012 05:29 PM, Paul Moore wrote:
> > On Tuesday, October 23, 2012 03:55:31 AM Eduardo Otubo wrote:
> >> This patch includes a second whitelist right before the main loop. It's
> >> a smaller and more restricted whitelist, excluding execve() among many
> >> others.
> >> 
> >> v2: * ctx changed to main_loop_ctx
> >> 
> >>  * seccomp_on now inside ifdef
> >>  * open syscall added to the main_loop whitelist
> >> 
> >> Signed-off-by: Eduardo Otubo 
> > 
> > Unfortunately qemu.org seems to be down for me today so I can't grab the
> > latest repo to review/verify this patch (some of my comments/assumptions
> > below may be off) but I'm a little confused, hopefully you guys can help
> > me out, read below ...
> > 
> > The first call to seccomp_install_filter() will setup a whitelist for the
> > syscalls that have been explicitly specified, all others will hit the
> > default action TRAP/KILL.  The second call to seccomp_install_filter()
> > will add a second whitelist for another set of explicitly specified
> > syscalls, all others will hit the default action TRAP/KILL.
> 
> That's correct.  The goal was to have a 2nd list that is a subset of the
> 1st list, and also not include execve() in the 2nd list.  At this point
> though, since it's late in the release, we've expanded the 2nd list to
> be the same as the 1st with the exception of execve() not being in the
> 2nd list.
> 
> > The problem occurs when the filters are executed in the kernel when a
> > syscall is executed.  On each syscall the first filter will be executed
> > and the action will either be ALLOW or TRAP/KILL, next the second filter
> > will be executed and the action will either be ALLOW or TRAP/KILL; since
> > the kernel always takes the most restrictive (lowest integer action
> > value) action when multiple filters are specified, I think your double
> > whitelist value is going to have some inherent problems.
> 
> That's something I hadn't thought of.  But TRAP and KILL won't exist
> together in our whitelists, and our 2nd whitelist is a subset of the
> 1st.  So do you think there would still be problems?

It doesn't really matter if the default action is TRAP and/or KILL, the point 
is that if you use a second whitelist after an initial whitelist the effective 
seccomp filter is going to be only the syscalls you explicitly allowed in the 
second whitelist.  When using multiple seccomp filters on a process, all 
filters are executed for each syscall and the most restrictive action of all 
the filters is the action that the kernel takes.

Don't get me wrong, I like the idea of progressively restricting QEMU, but if 
you are going to load multiple seccomp filters into the kernel, you almost 
certainly only want the first whitelist filter to be the union of all the 
seccomp filter you intend to load with all subsequent filters being blacklists 
which progressively remove syscalls which are allowed by the initial 
whitelist.

> > I might suggest an initial, fairly permissive
> > whitelist followed by a follow-on blacklist if you want to disable certain
> > syscalls.
> 
> I have to admit I'm nervous about this at this point in QEMU 1.3.  It's
> getting late in the cycle and we'd hoped to get this in earlier.  A more
> permissive whitelist is probably going to be the only way we'll
> successfully turn -sandbox on by default at this point in QEMU 1.3.

Thats fine, I just wanted to point out that I think the multiple whitelist 
approach is going to have some inherent problems.

-- 
paul moore
security and virtualization @ redhat




Re: [Qemu-devel] [PATCHv2 3/4] Support for "double whitelist" filters

2012-11-02 Thread Anthony Liguori
Paul Moore  writes:

> On Tuesday, October 23, 2012 03:55:31 AM Eduardo Otubo wrote:
>> This patch includes a second whitelist right before the main loop. It's
>> a smaller and more restricted whitelist, excluding execve() among many
>> others.
>> 
>> v2: * ctx changed to main_loop_ctx
>> * seccomp_on now inside ifdef
>> * open syscall added to the main_loop whitelist
>> 
>> Signed-off-by: Eduardo Otubo 
>
> Unfortunately qemu.org seems to be down for me today so I can't grab
> the 

qemu.org is up, just having DNS problems.  Use git.qemu-project.org
instead and you should be fine.

Regards,

Anthony Liguori

> latest repo to review/verify this patch (some of my comments/assumptions 
> below 
> may be off) but I'm a little confused, hopefully you guys can help me out, 
> read below ...
>
> The first call to seccomp_install_filter() will setup a whitelist for the 
> syscalls that have been explicitly specified, all others will hit the default 
> action TRAP/KILL.  The second call to seccomp_install_filter() will add a 
> second whitelist for another set of explicitly specified syscalls, all others 
> will hit the default action TRAP/KILL.
>
> The problem occurs when the filters are executed in the kernel when a syscall 
> is executed.  On each syscall the first filter will be executed and the 
> action 
> will either be ALLOW or TRAP/KILL, next the second filter will be executed 
> and 
> the action will either be ALLOW or TRAP/KILL; since the kernel always takes 
> the most restrictive (lowest integer action value) action when multiple 
> filters are specified, I think your double whitelist value is going to have 
> some inherent problems.  I might suggest an initial, fairly permissive 
> whitelist followed by a follow-on blacklist if you want to disable certain 
> syscalls.
>
> -- 
> paul moore
> security and virtualization @ redhat




Re: [Qemu-devel] [PATCHv2 3/4] Support for "double whitelist" filters

2012-11-02 Thread Corey Bryant



On 11/02/2012 05:29 PM, Paul Moore wrote:

On Tuesday, October 23, 2012 03:55:31 AM Eduardo Otubo wrote:

This patch includes a second whitelist right before the main loop. It's
a smaller and more restricted whitelist, excluding execve() among many
others.

v2: * ctx changed to main_loop_ctx
 * seccomp_on now inside ifdef
 * open syscall added to the main_loop whitelist

Signed-off-by: Eduardo Otubo 


Unfortunately qemu.org seems to be down for me today so I can't grab the
latest repo to review/verify this patch (some of my comments/assumptions below
may be off) but I'm a little confused, hopefully you guys can help me out,
read below ...

The first call to seccomp_install_filter() will setup a whitelist for the
syscalls that have been explicitly specified, all others will hit the default
action TRAP/KILL.  The second call to seccomp_install_filter() will add a
second whitelist for another set of explicitly specified syscalls, all others
will hit the default action TRAP/KILL.


That's correct.  The goal was to have a 2nd list that is a subset of the 
1st list, and also not include execve() in the 2nd list.  At this point 
though, since it's late in the release, we've expanded the 2nd list to 
be the same as the 1st with the exception of execve() not being in the 
2nd list.




The problem occurs when the filters are executed in the kernel when a syscall
is executed.  On each syscall the first filter will be executed and the action
will either be ALLOW or TRAP/KILL, next the second filter will be executed and
the action will either be ALLOW or TRAP/KILL; since the kernel always takes
the most restrictive (lowest integer action value) action when multiple
filters are specified, I think your double whitelist value is going to have
some inherent problems.


That's something I hadn't thought of.  But TRAP and KILL won't exist 
together in our whitelists, and our 2nd whitelist is a subset of the 
1st.  So do you think there would still be problems?



I might suggest an initial, fairly permissive
whitelist followed by a follow-on blacklist if you want to disable certain
syscalls.



I have to admit I'm nervous about this at this point in QEMU 1.3.  It's 
getting late in the cycle and we'd hoped to get this in earlier.  A more 
permissive whitelist is probably going to be the only way we'll 
successfully turn -sandbox on by default at this point in QEMU 1.3.


--
Regards,
Corey Bryant




Re: [Qemu-devel] [PATCHv2 3/4] Support for "double whitelist" filters

2012-11-02 Thread Paul Moore
On Tuesday, October 23, 2012 03:55:31 AM Eduardo Otubo wrote:
> This patch includes a second whitelist right before the main loop. It's
> a smaller and more restricted whitelist, excluding execve() among many
> others.
> 
> v2: * ctx changed to main_loop_ctx
> * seccomp_on now inside ifdef
> * open syscall added to the main_loop whitelist
> 
> Signed-off-by: Eduardo Otubo 

Unfortunately qemu.org seems to be down for me today so I can't grab the 
latest repo to review/verify this patch (some of my comments/assumptions below 
may be off) but I'm a little confused, hopefully you guys can help me out, 
read below ...

The first call to seccomp_install_filter() will setup a whitelist for the 
syscalls that have been explicitly specified, all others will hit the default 
action TRAP/KILL.  The second call to seccomp_install_filter() will add a 
second whitelist for another set of explicitly specified syscalls, all others 
will hit the default action TRAP/KILL.

The problem occurs when the filters are executed in the kernel when a syscall 
is executed.  On each syscall the first filter will be executed and the action 
will either be ALLOW or TRAP/KILL, next the second filter will be executed and 
the action will either be ALLOW or TRAP/KILL; since the kernel always takes 
the most restrictive (lowest integer action value) action when multiple 
filters are specified, I think your double whitelist value is going to have 
some inherent problems.  I might suggest an initial, fairly permissive 
whitelist followed by a follow-on blacklist if you want to disable certain 
syscalls.

-- 
paul moore
security and virtualization @ redhat




Re: [Qemu-devel] [PATCH v2] pc_sysfw: Always use alias for ISA BIOS region

2012-11-02 Thread Jordan Justen
I tested that flash device still works and the alias works with the
flash device.

I *did not* test vm state save/restore/migration.

Reviewed-by: Jordan Justen 

On Fri, Nov 2, 2012 at 11:55 AM, Jan Kiszka  wrote:
> This is no technical reason (anymore) for copying the ISA BIOS from the
> original region. Instead, refactor pc_isa_bios_init to serve both pflash
> and old-style BIOS setup.
>
> Unfortunately, the previous RAM-backed version created an additional
> vmstate section, content-wise redundant to the BIOS, but we still need
> to process it when working in compat mode.
>
> Signed-off-by: Jan Kiszka 
> ---
>
> Changes in v2:
>  - create dummy vmstate section to enable migration from 1.1/1.2
>
>  hw/pc_piix.c  |4 
>  hw/pc_sysfw.c |   55 +--
>  2 files changed, 25 insertions(+), 34 deletions(-)
>
> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
> index cfa839c..0051b2a 100644
> --- a/hw/pc_piix.c
> +++ b/hw/pc_piix.c
> @@ -386,6 +386,10 @@ static QEMUMachine pc_machine_v1_3 = {
>  .driver   = "VGA",\
>  .property = "mmio",\
>  .value= "off",\
> +},{\
> +.driver   = "pc-sysfw",\
> +.property = "compat_vmsection",\
> +.value= "on",\
>  }
>
>  static QEMUMachine pc_machine_v1_2 = {
> diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c
> index 9d7c5f4..a60f453 100644
> --- a/hw/pc_sysfw.c
> +++ b/hw/pc_sysfw.c
> @@ -38,40 +38,36 @@
>  typedef struct PcSysFwDevice {
>  SysBusDevice busdev;
>  uint8_t rom_only;
> +uint32_t compat_vmsection;
>  } PcSysFwDevice;
>
>  static void pc_isa_bios_init(MemoryRegion *rom_memory,
> - MemoryRegion *flash_mem,
> - int ram_size)
> + MemoryRegion *bios, bool compat_vmsection)
>  {
> +uint64_t bios_size = memory_region_size(bios);
>  int isa_bios_size;
>  MemoryRegion *isa_bios;
> -uint64_t flash_size;
> -void *flash_ptr, *isa_bios_ptr;
> -
> -flash_size = memory_region_size(flash_mem);
>
>  /* map the last 128KB of the BIOS in ISA space */
> -isa_bios_size = flash_size;
> +isa_bios_size = bios_size;
>  if (isa_bios_size > (128 * 1024)) {
>  isa_bios_size = 128 * 1024;
>  }
>  isa_bios = g_malloc(sizeof(*isa_bios));
> -memory_region_init_ram(isa_bios, "isa-bios", isa_bios_size);
> -vmstate_register_ram_global(isa_bios);
> +memory_region_init_alias(isa_bios, "isa-bios", bios,
> + bios_size - isa_bios_size, isa_bios_size);
>  memory_region_add_subregion_overlap(rom_memory,
>  0x10 - isa_bios_size,
>  isa_bios,
>  1);
> +memory_region_set_readonly(isa_bios, true);
>
> -/* copy ISA rom image from top of flash memory */
> -flash_ptr = memory_region_get_ram_ptr(flash_mem);
> -isa_bios_ptr = memory_region_get_ram_ptr(isa_bios);
> -memcpy(isa_bios_ptr,
> -   ((uint8_t*)flash_ptr) + (flash_size - isa_bios_size),
> -   isa_bios_size);
> +if (compat_vmsection) {
> +MemoryRegion *dummy_region = g_new(MemoryRegion, 1);
>
> -memory_region_set_readonly(isa_bios, true);
> +memory_region_init_ram(dummy_region, "isa-bios", isa_bios_size);
> +vmstate_register_ram_global(dummy_region);
> +}
>  }
>
>  static void pc_fw_add_pflash_drv(void)
> @@ -102,7 +98,7 @@ static void pc_fw_add_pflash_drv(void)
>  }
>
>  static void pc_system_flash_init(MemoryRegion *rom_memory,
> - DriveInfo *pflash_drv)
> + DriveInfo *pflash_drv, bool 
> compat_vmsection)
>  {
>  BlockDriverState *bdrv;
>  int64_t size;
> @@ -129,14 +125,14 @@ static void pc_system_flash_init(MemoryRegion 
> *rom_memory,
>   1, 0x, 0x, 0x, 0x, 
> 0);
>  flash_mem = pflash_cfi01_get_memory(system_flash);
>
> -pc_isa_bios_init(rom_memory, flash_mem, size);
> +pc_isa_bios_init(rom_memory, flash_mem, compat_vmsection);
>  }
>
>  static void old_pc_system_rom_init(MemoryRegion *rom_memory)
>  {
>  char *filename;
> -MemoryRegion *bios, *isa_bios;
> -int bios_size, isa_bios_size;
> +MemoryRegion *bios;
> +int bios_size;
>  int ret;
>
>  /* BIOS load */
> @@ -167,19 +163,7 @@ static void old_pc_system_rom_init(MemoryRegion 
> *rom_memory)
>  g_free(filename);
>  }
>
> -/* map the last 128KB of the BIOS in ISA space */
> -isa_bios_size = bios_size;
> -if (isa_bios_size > (128 * 1024)) {
> -isa_bios_size = 128 * 1024;
> -}
> -isa_bios = g_malloc(sizeof(*isa_bios));
> -memory_region_init_alias(isa_bios, "isa-bios", bios,
> - bios_size - isa_bios_size, isa_bios_size);
> -memory_region_a

[Qemu-devel] [PATCH] build: pthread_atfork() needs include of pthread.h

2012-11-02 Thread Anthony Liguori
Cc: Paolo Bonzini 
Signed-off-by: Anthony Liguori 
---
 qemu-timer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qemu-timer.c b/qemu-timer.c
index 7b2217a..8d9cf38 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -30,6 +30,9 @@
 #include "hw/hw.h"
 
 #include "qemu-timer.h"
+#ifdef CONFIG_POSIX
+#include 
+#endif
 
 #ifdef _WIN32
 #include 
-- 
1.8.0




Re: [Qemu-devel] [PATCH] virtio: limit avail bytes lookahead

2012-11-02 Thread Stefan Hajnoczi
On Fri, Nov 2, 2012 at 3:48 PM, Michael S. Tsirkin  wrote:
> On Fri, Nov 02, 2012 at 11:18:18AM +0100, Stefan Hajnoczi wrote:
>> On Thu, Nov 1, 2012 at 5:07 PM, Michael S. Tsirkin  wrote:
>> > Commit 0d8d7690850eb0cf2b2b60933cf47669a6b6f18f introduced
>> > a regression in virtio-net performance because it looks
>> > into the ring aggressively while we really only care
>> > about a single packet worth of buffers.
>> > To fix, add parameters limiting lookahead, and
>> > use in virtqueue_avail_bytes.
>> >
>> > Signed-off-by: Michael S. Tsirkin 
>> > Reported-by: Edivaldo de Araujo Pereira 
>>
>> Nice, much simpler than the ideas I had.
>>
>> Reviewed-by: Stefan Hajnoczi 
>
> Anthony could you apply this out of band please so this stops
> biting people?

Especially for the 1.3 release so that we don't have a virtio
performance regression.

Stefan



Re: [Qemu-devel] [PATCH] raw-posix: inline paio_ioctl into hdev_aio_ioctl

2012-11-02 Thread Stefan Hajnoczi
On Fri, Nov 2, 2012 at 4:14 PM, Paolo Bonzini  wrote:
> clang now warns about an unused function:
>   CCblock/raw-posix.o
> block/raw-posix.c:707:26: warning: unused function paio_ioctl
> [-Wunused-function]
> static BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,
>  ^
> 1 warning generated.
>
> because the only use of paio_ioctl() is inside a #if defined(__linux__)
> guard and it is static now.
>
> Reported-by: Peter Maydell 
> Signed-off-by: Paolo Bonzini 
> ---
>  block/raw-posix.c | 27 ++-
>  1 file modificato, 10 inserzioni(+), 17 rimozioni(-)

Reviewed-by: Stefan Hajnoczi 



Re: [Qemu-devel] [PATCH] ui/cocoa.m: Update to new DisplayChangeListener member names

2012-11-02 Thread Anthony Liguori
Peter Maydell  writes:

> Commit a93a4a2 changed the names of some fields in DisplayChangeListener
> and broke compilation of the cocoa UI. Update to the new names.
>
> Signed-off-by: Peter Maydell 

Applied. Thanks.

Regards,

Anthony Liguori

> ---
>  ui/cocoa.m | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 2383646..87d2e44 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -1017,8 +1017,8 @@ void cocoa_display_init(DisplayState *ds, int 
> full_screen)
>  dcl = g_malloc0(sizeof(DisplayChangeListener));
>  
>  // register vga output callbacks
> -dcl->dpy_update = cocoa_update;
> -dcl->dpy_resize = cocoa_resize;
> +dcl->dpy_gfx_update = cocoa_update;
> +dcl->dpy_gfx_resize = cocoa_resize;
>  dcl->dpy_refresh = cocoa_refresh;
>  
>   register_displaychangelistener(ds, dcl);
> -- 
> 1.7.11.4



Re: [Qemu-devel] [PULL buildfix] QOM CPUState patch queue 2012-11-02

2012-11-02 Thread Anthony Liguori
Andreas Färber  writes:

> Hello,
>
> Here's a build fix for {i386,x86_64}-linux-user. Please pull.

Pulled. Thanks.

Regards,

Anthony Liguori

>
> Regards,
> Andreas
>
>
> The following changes since commit 4ba79505f43bd0ace35c3fe42197eb02e7e0478e:
>
>   Merge remote-tracking branch 'kraxel/pixman.v3' into staging (2012-11-01 
> 11:14:39 -0500)
>
> are available in the git repository at:
>
>
>   git://github.com/afaerber/qemu-cpu.git qom-cpu
>
> for you to fetch changes up to e4ab0d6b0d1118a90238d8194eedb91aab15ebe1:
>
>   target-i386: cpu: fix --disable-kvm compilation (2012-11-02 17:55:29 +0100)
>
> 
> Eduardo Habkost (1):
>   target-i386: cpu: fix --disable-kvm compilation
>
>  target-i386/cpu.c |4 
>  1 Datei geändert, 4 Zeilen hinzugefügt(+)



Re: [Qemu-devel] [PULL 00/12] Incoming migration coroutine

2012-11-02 Thread Anthony Liguori
Paolo Bonzini  writes:

> Anthony,
>
> The following changes since commit 4ba79505f43bd0ace35c3fe42197eb02e7e0478e:
>
>   Merge remote-tracking branch 'kraxel/pixman.v3' into staging (2012-11-01 
> 11:14:39 -0500)
>
> are available in the git repository at:

Pulled. Thanks.

Regards,

Anthony Liguori

>
>
>   git://github.com/bonzini/qemu.git migr-coroutine
>
> for you to fetch changes up to 82a4da79fd6c108400637143f8439c2364bdb21e:
>
>   migration: move process_incoming_migration to a coroutine (2012-11-02 
> 18:35:08 +0100)
>
> With these patches, the monitor and the NBD server are responsive during
> migration.
>
> The first ten patches are just cleanups, generalizing some parts of
> QEMUFile and improving the way migration sockets are closed.
>
> The last two actually implement the feature.  They are the opposite
> change of the nonblocking->blocking change that you implemented for the
> migration thread.  However, the change is much simpler because we have
> no timers, and because of the use of coroutines.
>
> Without coroutines (and as in non-threaded migration), you have
> to proceed in two steps: first collect data in a buffer, then
> write it.  This lets you handle EAGAIN only at precise points in
> buffered_flush/buffered_put_buffer, so that you can restart writing
> in migrate_fd_put_notify.  This "checkpointing" is the reason why
> QEMUFileBuffered exists.  With coroutines, you can just stop whenever
> you want with qemu_coroutine_yield.  As soon as select tells you that
> you can read, you'll re-enter directly in qemu_get_buffer, read more
> data and pass it to the loading routines.
>
> Paolo
> 
> Paolo Bonzini (12):
>   migration: unify stdio-based QEMUFile operations
>   migration: consolidate QEMUFile methods in a single QEMUFileOps struct
>   migration: add qemu_get_fd
>   migration: replace qemu_stdio_fd with qemu_get_fd
>   migration: clean up server sockets and handlers before invoking 
> process_incoming_migration
>   migration: use migrate_fd_close in migrate_fd_cleanup
>   migration: use closesocket, not close
>   migration: xxx_close will only be called once
>   migration: close socket QEMUFile from socket_close
>   migration: move qemu_fclose to process_incoming_migration
>   migration: handle EAGAIN while reading QEMUFile
>   migration: move process_incoming_migration to a coroutine
>
>  buffered_file.c  |  21 +--
>  migration-exec.c |  19 +++---
>  migration-fd.c   |  36 +--
>  migration-tcp.c  |  19 +++---
>  migration-unix.c |  17 +++--
>  migration.c  |  46 ++
>  qemu-file.h  |  23 ---
>  savevm.c | 188 
> ---
>  8 file modificati, 215 inserzioni(+), 154 rimozioni(-)
> -- 
> 1.7.12.1




Re: [Qemu-devel] [PATCH] xenfb: fix build breakage caused by console cleanup series

2012-11-02 Thread Anthony Liguori
Gerd Hoffmann  writes:

> Console cleanup series renamed dpy_resize and dpy_update all over the
> tree, but hw/xenfb.c was forgotten.  Update it too so it builds again.
>
> Reported-by: Jan Kiszka 
> Signed-off-by: Gerd Hoffmann 

Applied. Thanks.

Regards,

Anthony Liguori

> ---
>  hw/xenfb.c |4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/xenfb.c b/hw/xenfb.c
> index ef24c33..442a63a 100644
> --- a/hw/xenfb.c
> +++ b/hw/xenfb.c
> @@ -648,7 +648,7 @@ static void xenfb_guest_copy(struct XenFB *xenfb, int x, 
> int y, int w, int h)
>  xen_be_printf(&xenfb->c.xendev, 0, "%s: oops: convert %d -> %d 
> bpp?\n",
>__FUNCTION__, xenfb->depth, bpp);
>  
> -dpy_update(xenfb->c.ds, x, y, w, h);
> +dpy_gfx_update(xenfb->c.ds, x, y, w, h);
>  }
>  
>  #ifdef XENFB_TYPE_REFRESH_PERIOD
> @@ -766,7 +766,7 @@ static void xenfb_update(void *opaque)
>  xen_be_printf(&xenfb->c.xendev, 1, "update: resizing: %dx%d @ %d 
> bpp%s\n",
>xenfb->width, xenfb->height, xenfb->depth,
>is_buffer_shared(xenfb->c.ds->surface) ? " (shared)" : 
> "");
> -dpy_resize(xenfb->c.ds);
> +dpy_gfx_resize(xenfb->c.ds);
>  xenfb->up_fullscreen = 1;
>  }
>  
> -- 
> 1.7.1



[Qemu-devel] qemu.org DNS status

2012-11-02 Thread anthony

Hi,

I wanted to update everyone on the qemu.org DNS status.  This morning it
was reported that the two nameservers that qemu.org is configured to use
are down.  I do not have access to the DNS records for qemu.org as they
are graciously donated by a third party.

I've contacted the owner of the records who has been fairly responsive
in the past.

In the interim, I've setup an alternative hostname, qemu-project.org,
that can be used as an alternative to qemu.org.  This hostname will
remain active even when qemu.org is restored.

Sorry for the inconvenience.

Regards,

Anthony Liguori



[Qemu-devel] [PATCH 05/12] migration: clean up server sockets and handlers before invoking process_incoming_migration

2012-11-02 Thread Paolo Bonzini
A first step towards making a common "suffix" for all migration protocols,
and moving it to process_incoming_migration.

Reviewed-by: Orit Wasserman 
Signed-off-by: Paolo Bonzini 
---
 migration-exec.c | 2 +-
 migration-fd.c   | 2 +-
 migration-tcp.c  | 7 +++
 migration-unix.c | 7 +++
 4 file modificati, 8 inserzioni(+), 10 rimozioni(-)

diff --git a/migration-exec.c b/migration-exec.c
index 452bf07..014c60f 100644
--- a/migration-exec.c
+++ b/migration-exec.c
@@ -87,8 +87,8 @@ static void exec_accept_incoming_migration(void *opaque)
 {
 QEMUFile *f = opaque;
 
-process_incoming_migration(f);
 qemu_set_fd_handler2(qemu_get_fd(f), NULL, NULL, NULL, NULL);
+process_incoming_migration(f);
 qemu_fclose(f);
 }
 
diff --git a/migration-fd.c b/migration-fd.c
index b47b222..a4cd83f 100644
--- a/migration-fd.c
+++ b/migration-fd.c
@@ -92,8 +92,8 @@ static void fd_accept_incoming_migration(void *opaque)
 {
 QEMUFile *f = opaque;
 
-process_incoming_migration(f);
 qemu_set_fd_handler2(qemu_get_fd(f), NULL, NULL, NULL, NULL);
+process_incoming_migration(f);
 qemu_fclose(f);
 }
 
diff --git a/migration-tcp.c b/migration-tcp.c
index 46f6ac5..96a832c 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -88,12 +88,14 @@ static void tcp_accept_incoming_migration(void *opaque)
 do {
 c = qemu_accept(s, (struct sockaddr *)&addr, &addrlen);
 } while (c == -1 && socket_error() == EINTR);
+qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
+close(s);
 
 DPRINTF("accepted migration\n");
 
 if (c == -1) {
 fprintf(stderr, "could not accept migration connection\n");
-goto out2;
+goto out;
 }
 
 f = qemu_fopen_socket(c);
@@ -106,9 +108,6 @@ static void tcp_accept_incoming_migration(void *opaque)
 qemu_fclose(f);
 out:
 close(c);
-out2:
-qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
-close(s);
 }
 
 void tcp_start_incoming_migration(const char *host_port, Error **errp)
diff --git a/migration-unix.c b/migration-unix.c
index ed3db3a..5dc49cd 100644
--- a/migration-unix.c
+++ b/migration-unix.c
@@ -88,12 +88,14 @@ static void unix_accept_incoming_migration(void *opaque)
 do {
 c = qemu_accept(s, (struct sockaddr *)&addr, &addrlen);
 } while (c == -1 && errno == EINTR);
+qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
+close(s);
 
 DPRINTF("accepted migration\n");
 
 if (c == -1) {
 fprintf(stderr, "could not accept migration connection\n");
-goto out2;
+goto out;
 }
 
 f = qemu_fopen_socket(c);
@@ -106,9 +108,6 @@ static void unix_accept_incoming_migration(void *opaque)
 qemu_fclose(f);
 out:
 close(c);
-out2:
-qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
-close(s);
 }
 
 void unix_start_incoming_migration(const char *path, Error **errp)
-- 
1.7.12.1





[Qemu-devel] [PATCH 09/12] migration: close socket QEMUFile from socket_close

2012-11-02 Thread Paolo Bonzini
The common suffix now is process_incoming_migration+qemu_fclose.

Reviewed-by: Orit Wasserman 
Signed-off-by: Paolo Bonzini 
---
 migration-tcp.c  | 2 ++
 migration-unix.c | 2 ++
 savevm.c | 1 +
 3 file modificati, 5 inserzioni(+)

diff --git a/migration-tcp.c b/migration-tcp.c
index bb27ce8..1279cc9 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -103,6 +103,8 @@ static void tcp_accept_incoming_migration(void *opaque)
 
 process_incoming_migration(f);
 qemu_fclose(f);
+return;
+
 out:
 closesocket(c);
 }
diff --git a/migration-unix.c b/migration-unix.c
index 9b5521e..96ea71b 100644
--- a/migration-unix.c
+++ b/migration-unix.c
@@ -103,6 +103,8 @@ static void unix_accept_incoming_migration(void *opaque)
 
 process_incoming_migration(f);
 qemu_fclose(f);
+return;
+
 out:
 close(c);
 }
diff --git a/savevm.c b/savevm.c
index 0ab1ad4..cdad3ad 100644
--- a/savevm.c
+++ b/savevm.c
@@ -213,6 +213,7 @@ static int socket_get_buffer(void *opaque, uint8_t *buf, 
int64_t pos, int size)
 static int socket_close(void *opaque)
 {
 QEMUFileSocket *s = opaque;
+closesocket(s->fd);
 g_free(s);
 return 0;
 }
-- 
1.7.12.1





[Qemu-devel] [PATCH 10/12] migration: move qemu_fclose to process_incoming_migration

2012-11-02 Thread Paolo Bonzini
The common suffix is now just process_incoming_migration.

Reviewed-by: Orit Wasserman 
Signed-off-by: Paolo Bonzini 
---
 migration-exec.c | 1 -
 migration-fd.c   | 1 -
 migration-tcp.c  | 1 -
 migration-unix.c | 1 -
 migration.c  | 6 +-
 5 file modificati, 5 inserzioni(+), 5 rimozioni(-)

diff --git a/migration-exec.c b/migration-exec.c
index 2ce7770..2b6fcb4 100644
--- a/migration-exec.c
+++ b/migration-exec.c
@@ -87,7 +87,6 @@ static void exec_accept_incoming_migration(void *opaque)
 
 qemu_set_fd_handler2(qemu_get_fd(f), NULL, NULL, NULL, NULL);
 process_incoming_migration(f);
-qemu_fclose(f);
 }
 
 void exec_start_incoming_migration(const char *command, Error **errp)
diff --git a/migration-fd.c b/migration-fd.c
index c678b23..5fe28e0 100644
--- a/migration-fd.c
+++ b/migration-fd.c
@@ -91,7 +91,6 @@ static void fd_accept_incoming_migration(void *opaque)
 
 qemu_set_fd_handler2(qemu_get_fd(f), NULL, NULL, NULL, NULL);
 process_incoming_migration(f);
-qemu_fclose(f);
 }
 
 void fd_start_incoming_migration(const char *infd, Error **errp)
diff --git a/migration-tcp.c b/migration-tcp.c
index 1279cc9..5e855fe 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -102,7 +102,6 @@ static void tcp_accept_incoming_migration(void *opaque)
 }
 
 process_incoming_migration(f);
-qemu_fclose(f);
 return;
 
 out:
diff --git a/migration-unix.c b/migration-unix.c
index 96ea71b..dba72b4 100644
--- a/migration-unix.c
+++ b/migration-unix.c
@@ -102,7 +102,6 @@ static void unix_accept_incoming_migration(void *opaque)
 }
 
 process_incoming_migration(f);
-qemu_fclose(f);
 return;
 
 out:
diff --git a/migration.c b/migration.c
index a63596f..2741d97 100644
--- a/migration.c
+++ b/migration.c
@@ -85,7 +85,11 @@ void qemu_start_incoming_migration(const char *uri, Error 
**errp)
 
 void process_incoming_migration(QEMUFile *f)
 {
-if (qemu_loadvm_state(f) < 0) {
+int ret;
+
+ret = qemu_loadvm_state(f);
+qemu_fclose(f);
+if (ret < 0) {
 fprintf(stderr, "load of migration failed\n");
 exit(0);
 }
-- 
1.7.12.1





[Qemu-devel] [PATCH v2] pc_sysfw: Always use alias for ISA BIOS region

2012-11-02 Thread Jan Kiszka
This is no technical reason (anymore) for copying the ISA BIOS from the
original region. Instead, refactor pc_isa_bios_init to serve both pflash
and old-style BIOS setup.

Unfortunately, the previous RAM-backed version created an additional
vmstate section, content-wise redundant to the BIOS, but we still need
to process it when working in compat mode.

Signed-off-by: Jan Kiszka 
---

Changes in v2:
 - create dummy vmstate section to enable migration from 1.1/1.2

 hw/pc_piix.c  |4 
 hw/pc_sysfw.c |   55 +--
 2 files changed, 25 insertions(+), 34 deletions(-)

diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index cfa839c..0051b2a 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -386,6 +386,10 @@ static QEMUMachine pc_machine_v1_3 = {
 .driver   = "VGA",\
 .property = "mmio",\
 .value= "off",\
+},{\
+.driver   = "pc-sysfw",\
+.property = "compat_vmsection",\
+.value= "on",\
 }
 
 static QEMUMachine pc_machine_v1_2 = {
diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c
index 9d7c5f4..a60f453 100644
--- a/hw/pc_sysfw.c
+++ b/hw/pc_sysfw.c
@@ -38,40 +38,36 @@
 typedef struct PcSysFwDevice {
 SysBusDevice busdev;
 uint8_t rom_only;
+uint32_t compat_vmsection;
 } PcSysFwDevice;
 
 static void pc_isa_bios_init(MemoryRegion *rom_memory,
- MemoryRegion *flash_mem,
- int ram_size)
+ MemoryRegion *bios, bool compat_vmsection)
 {
+uint64_t bios_size = memory_region_size(bios);
 int isa_bios_size;
 MemoryRegion *isa_bios;
-uint64_t flash_size;
-void *flash_ptr, *isa_bios_ptr;
-
-flash_size = memory_region_size(flash_mem);
 
 /* map the last 128KB of the BIOS in ISA space */
-isa_bios_size = flash_size;
+isa_bios_size = bios_size;
 if (isa_bios_size > (128 * 1024)) {
 isa_bios_size = 128 * 1024;
 }
 isa_bios = g_malloc(sizeof(*isa_bios));
-memory_region_init_ram(isa_bios, "isa-bios", isa_bios_size);
-vmstate_register_ram_global(isa_bios);
+memory_region_init_alias(isa_bios, "isa-bios", bios,
+ bios_size - isa_bios_size, isa_bios_size);
 memory_region_add_subregion_overlap(rom_memory,
 0x10 - isa_bios_size,
 isa_bios,
 1);
+memory_region_set_readonly(isa_bios, true);
 
-/* copy ISA rom image from top of flash memory */
-flash_ptr = memory_region_get_ram_ptr(flash_mem);
-isa_bios_ptr = memory_region_get_ram_ptr(isa_bios);
-memcpy(isa_bios_ptr,
-   ((uint8_t*)flash_ptr) + (flash_size - isa_bios_size),
-   isa_bios_size);
+if (compat_vmsection) {
+MemoryRegion *dummy_region = g_new(MemoryRegion, 1);
 
-memory_region_set_readonly(isa_bios, true);
+memory_region_init_ram(dummy_region, "isa-bios", isa_bios_size);
+vmstate_register_ram_global(dummy_region);
+}
 }
 
 static void pc_fw_add_pflash_drv(void)
@@ -102,7 +98,7 @@ static void pc_fw_add_pflash_drv(void)
 }
 
 static void pc_system_flash_init(MemoryRegion *rom_memory,
- DriveInfo *pflash_drv)
+ DriveInfo *pflash_drv, bool compat_vmsection)
 {
 BlockDriverState *bdrv;
 int64_t size;
@@ -129,14 +125,14 @@ static void pc_system_flash_init(MemoryRegion *rom_memory,
  1, 0x, 0x, 0x, 0x, 0);
 flash_mem = pflash_cfi01_get_memory(system_flash);
 
-pc_isa_bios_init(rom_memory, flash_mem, size);
+pc_isa_bios_init(rom_memory, flash_mem, compat_vmsection);
 }
 
 static void old_pc_system_rom_init(MemoryRegion *rom_memory)
 {
 char *filename;
-MemoryRegion *bios, *isa_bios;
-int bios_size, isa_bios_size;
+MemoryRegion *bios;
+int bios_size;
 int ret;
 
 /* BIOS load */
@@ -167,19 +163,7 @@ static void old_pc_system_rom_init(MemoryRegion 
*rom_memory)
 g_free(filename);
 }
 
-/* map the last 128KB of the BIOS in ISA space */
-isa_bios_size = bios_size;
-if (isa_bios_size > (128 * 1024)) {
-isa_bios_size = 128 * 1024;
-}
-isa_bios = g_malloc(sizeof(*isa_bios));
-memory_region_init_alias(isa_bios, "isa-bios", bios,
- bios_size - isa_bios_size, isa_bios_size);
-memory_region_add_subregion_overlap(rom_memory,
-0x10 - isa_bios_size,
-isa_bios,
-1);
-memory_region_set_readonly(isa_bios, true);
+pc_isa_bios_init(rom_memory, bios, false);
 
 /* map all the bios at the top of memory */
 memory_region_add_subregion(rom_memory,
@@ -224,7 +208,8 @@ void pc_system_firmware_init(MemoryRegion *rom_mem

[Qemu-devel] [PATCH 12/12] migration: move process_incoming_migration to a coroutine

2012-11-02 Thread Paolo Bonzini
The final part of incoming migration, which now consists of
process_incoming_migration for all protocols, is thus made non-blocking.

Reviewed-by: Orit Wasserman 
Signed-off-by: Paolo Bonzini 
---
 migration.c | 21 -
 1 file modificato, 20 inserzioni(+). 1 rimozione(-)

diff --git a/migration.c b/migration.c
index 2741d97..73ce170 100644
--- a/migration.c
+++ b/migration.c
@@ -83,11 +83,13 @@ void qemu_start_incoming_migration(const char *uri, Error 
**errp)
 }
 }
 
-void process_incoming_migration(QEMUFile *f)
+static void process_incoming_migration_co(void *opaque)
 {
+QEMUFile *f = opaque;
 int ret;
 
 ret = qemu_loadvm_state(f);
+qemu_set_fd_handler(qemu_get_fd(f), NULL, NULL, NULL);
 qemu_fclose(f);
 if (ret < 0) {
 fprintf(stderr, "load of migration failed\n");
@@ -107,6 +109,23 @@ void process_incoming_migration(QEMUFile *f)
 }
 }
 
+static void enter_migration_coroutine(void *opaque)
+{
+Coroutine *co = opaque;
+qemu_coroutine_enter(co, NULL);
+}
+
+void process_incoming_migration(QEMUFile *f)
+{
+Coroutine *co = qemu_coroutine_create(process_incoming_migration_co);
+int fd = qemu_get_fd(f);
+
+assert(fd != -1);
+socket_set_nonblock(fd);
+qemu_set_fd_handler(fd, enter_migration_coroutine, NULL, co);
+qemu_coroutine_enter(co, f);
+}
+
 /* amount of nanoseconds we are willing to wait for migration to be down.
  * the choice of nanoseconds is because it is the maximum resolution that
  * get_clock() can achieve. It is an internal measure. All user-visible
-- 
1.7.12.1




[Qemu-devel] [PATCH 03/12] migration: add qemu_get_fd

2012-11-02 Thread Paolo Bonzini
Reviewed-by: Orit Wasserman 
Signed-off-by: Paolo Bonzini 
---
 buffered_file.c |  8 
 qemu-file.h |  6 ++
 savevm.c| 27 +++
 3 file modificati, 41 inserzioni(+)

diff --git a/buffered_file.c b/buffered_file.c
index a5c0b12..bd0f61d 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -174,6 +174,13 @@ static int buffered_close(void *opaque)
  *   1: Time to stop
  *   negative: There has been an error
  */
+static int buffered_get_fd(void *opaque)
+{
+QEMUFileBuffered *s = opaque;
+
+return qemu_get_fd(s->file);
+}
+
 static int buffered_rate_limit(void *opaque)
 {
 QEMUFileBuffered *s = opaque;
@@ -235,6 +242,7 @@ static void buffered_rate_tick(void *opaque)
 }
 
 static const QEMUFileOps buffered_file_ops = {
+.get_fd = buffered_get_fd,
 .put_buffer = buffered_put_buffer,
 .close =  buffered_close,
 .rate_limit = buffered_rate_limit,
diff --git a/qemu-file.h b/qemu-file.h
index c89e8e0..d552f5d 100644
--- a/qemu-file.h
+++ b/qemu-file.h
@@ -47,6 +47,10 @@ typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t 
*buf,
  */
 typedef int (QEMUFileCloseFunc)(void *opaque);
 
+/* Called to return the OS file descriptor associated to the QEMUFile.
+ */
+typedef int (QEMUFileGetFD)(void *opaque);
+
 /* Called to determine if the file has exceeded its bandwidth allocation.  The
  * bandwidth capping is a soft limit, not a hard limit.
  */
@@ -63,6 +67,7 @@ typedef struct QEMUFileOps {
 QEMUFilePutBufferFunc *put_buffer;
 QEMUFileGetBufferFunc *get_buffer;
 QEMUFileCloseFunc *close;
+QEMUFileGetFD *get_fd;
 QEMUFileRateLimit *rate_limit;
 QEMUFileSetRateLimit *set_rate_limit;
 QEMUFileGetRateLimit *get_rate_limit;
@@ -74,6 +79,7 @@ QEMUFile *qemu_fdopen(int fd, const char *mode);
 QEMUFile *qemu_fopen_socket(int fd);
 QEMUFile *qemu_popen(FILE *popen_file, const char *mode);
 QEMUFile *qemu_popen_cmd(const char *command, const char *mode);
+int qemu_get_fd(QEMUFile *f);
 int qemu_stdio_fd(QEMUFile *f);
 int qemu_fclose(QEMUFile *f);
 void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
diff --git a/savevm.c b/savevm.c
index a4158ec..a58fe9a 100644
--- a/savevm.c
+++ b/savevm.c
@@ -188,6 +188,13 @@ typedef struct QEMUFileSocket
 QEMUFile *file;
 } QEMUFileSocket;
 
+static int socket_get_fd(void *opaque)
+{
+QEMUFileSocket *s = opaque;
+
+return s->fd;
+}
+
 static int socket_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
 {
 QEMUFileSocket *s = opaque;
@@ -210,6 +217,13 @@ static int socket_close(void *opaque)
 return 0;
 }
 
+static int stdio_get_fd(void *opaque)
+{
+QEMUFileStdio *s = opaque;
+
+return fileno(s->stdio_file);
+}
+
 static int stdio_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int 
size)
 {
 QEMUFileStdio *s = opaque;
@@ -253,11 +267,13 @@ static int stdio_fclose(void *opaque)
 }
 
 static const QEMUFileOps stdio_pipe_read_ops = {
+.get_fd = stdio_get_fd,
 .get_buffer = stdio_get_buffer,
 .close =  stdio_pclose
 };
 
 static const QEMUFileOps stdio_pipe_write_ops = {
+.get_fd = stdio_get_fd,
 .put_buffer = stdio_put_buffer,
 .close =  stdio_pclose
 };
@@ -307,11 +323,13 @@ int qemu_stdio_fd(QEMUFile *f)
 }
 
 static const QEMUFileOps stdio_file_read_ops = {
+.get_fd = stdio_get_fd,
 .get_buffer = stdio_get_buffer,
 .close =  stdio_fclose
 };
 
 static const QEMUFileOps stdio_file_write_ops = {
+.get_fd = stdio_get_fd,
 .put_buffer = stdio_put_buffer,
 .close =  stdio_fclose
 };
@@ -345,6 +363,7 @@ fail:
 }
 
 static const QEMUFileOps socket_read_ops = {
+.get_fd = socket_get_fd,
 .get_buffer = socket_get_buffer,
 .close =  socket_close
 };
@@ -492,6 +511,14 @@ static void qemu_fill_buffer(QEMUFile *f)
 qemu_file_set_error(f, len);
 }
 
+int qemu_get_fd(QEMUFile *f)
+{
+if (f->ops->get_fd) {
+return f->ops->get_fd(f->opaque);
+}
+return -1;
+}
+
 /** Closes the file
  *
  * Returns negative error value if any error happened on previous operations or
-- 
1.7.12.1





[Qemu-devel] [PATCH 11/12] migration: handle EAGAIN while reading QEMUFile

2012-11-02 Thread Paolo Bonzini
This will never happen right now (the assertion would fail).  The
next patch will set the socket or pipe in non-blocking mode, thus
enabling this part of the code.

Coroutines can just stop whenever they want with qemu_coroutine_yield.
As soon as select tells the main loop that the migration stream is
readable, the coroutine is re-entered directly in qemu_get_buffer,
where it will read more data and pass it to the loading routines.

Signed-off-by: Paolo Bonzini 
---
 savevm.c | 30 --
 1 file modificato, 24 inserzioni(+), 6 rimozioni(-)

diff --git a/savevm.c b/savevm.c
index cdad3ad..5d04d59 100644
--- a/savevm.c
+++ b/savevm.c
@@ -200,13 +200,22 @@ static int socket_get_buffer(void *opaque, uint8_t *buf, 
int64_t pos, int size)
 QEMUFileSocket *s = opaque;
 ssize_t len;
 
-do {
+for (;;) {
 len = qemu_recv(s->fd, buf, size, 0);
-} while (len == -1 && socket_error() == EINTR);
+if (len != -1) {
+break;
+}
+if (socket_error() == EAGAIN) {
+assert(qemu_in_coroutine());
+qemu_coroutine_yield();
+} else if (socket_error() != EINTR) {
+break;
+}
+}
 
-if (len == -1)
+if (len == -1) {
 len = -socket_error();
-
+}
 return len;
 }
 
@@ -237,10 +246,19 @@ static int stdio_get_buffer(void *opaque, uint8_t *buf, 
int64_t pos, int size)
 FILE *fp = s->stdio_file;
 int bytes;
 
-do {
+for (;;) {
 clearerr(fp);
 bytes = fread(buf, 1, size, fp);
-} while ((bytes == 0) && ferror(fp) && (errno == EINTR));
+if (bytes != 0 || !ferror(fp)) {
+break;
+}
+if (errno == EAGAIN) {
+assert(qemu_in_coroutine());
+qemu_coroutine_yield();
+} else if (errno != EINTR) {
+break;
+}
+}
 return bytes;
 }
 
-- 
1.7.12.1





[Qemu-devel] [PATCH 01/12] migration: unify stdio-based QEMUFile operations

2012-11-02 Thread Paolo Bonzini
Now that qemu_fseek does not exist anymore, there is no reason to do
an fseek before fread/fwrite when operating on an stdio file.
Thus, unify the get/put_buffer callbacks used by qemu_fopen
with those used for pipes.

Reviewed-by: Orit Wasserman 
Signed-off-by: Paolo Bonzini 
---
 savevm.c | 19 ++-
 1 file modificato, 2 inserzioni(+), 17 rimozioni(-)

diff --git a/savevm.c b/savevm.c
index 43d3d1b..cfcf918 100644
--- a/savevm.c
+++ b/savevm.c
@@ -343,21 +343,6 @@ QEMUFile *qemu_fopen_socket(int fd)
 return s->file;
 }
 
-static int file_put_buffer(void *opaque, const uint8_t *buf,
-int64_t pos, int size)
-{
-QEMUFileStdio *s = opaque;
-fseek(s->stdio_file, pos, SEEK_SET);
-return fwrite(buf, 1, size, s->stdio_file);
-}
-
-static int file_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
-{
-QEMUFileStdio *s = opaque;
-fseek(s->stdio_file, pos, SEEK_SET);
-return fread(buf, 1, size, s->stdio_file);
-}
-
 QEMUFile *qemu_fopen(const char *filename, const char *mode)
 {
 QEMUFileStdio *s;
@@ -376,10 +361,10 @@ QEMUFile *qemu_fopen(const char *filename, const char 
*mode)
 goto fail;
 
 if(mode[0] == 'w') {
-s->file = qemu_fopen_ops(s, file_put_buffer, NULL, stdio_fclose, 
+s->file = qemu_fopen_ops(s, stdio_put_buffer, NULL, stdio_fclose,
 NULL, NULL, NULL);
 } else {
-s->file = qemu_fopen_ops(s, NULL, file_get_buffer, stdio_fclose, 
+s->file = qemu_fopen_ops(s, NULL, stdio_get_buffer, stdio_fclose,
   NULL, NULL, NULL);
 }
 return s->file;
-- 
1.7.12.1





[Qemu-devel] [PATCH 07/12] migration: use closesocket, not close

2012-11-02 Thread Paolo Bonzini
Windows requires this.  Migration does not quite work under Windows
but let's be uniform across QEMU.

Reviewed-by: Orit Wasserman 
Signed-off-by: Paolo Bonzini 
---
 migration-tcp.c | 6 +++---
 1 file modificato, 3 inserzioni(+), 3 rimozioni(-)

diff --git a/migration-tcp.c b/migration-tcp.c
index 96a832c..1a12f17 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -45,7 +45,7 @@ static int tcp_close(MigrationState *s)
 int r = 0;
 DPRINTF("tcp_close\n");
 if (s->fd != -1) {
-if (close(s->fd) < 0) {
+if (closesocket(s->fd) < 0) {
 r = -errno;
 }
 s->fd = -1;
@@ -89,7 +89,7 @@ static void tcp_accept_incoming_migration(void *opaque)
 c = qemu_accept(s, (struct sockaddr *)&addr, &addrlen);
 } while (c == -1 && socket_error() == EINTR);
 qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
-close(s);
+closesocket(s);
 
 DPRINTF("accepted migration\n");
 
@@ -107,7 +107,7 @@ static void tcp_accept_incoming_migration(void *opaque)
 process_incoming_migration(f);
 qemu_fclose(f);
 out:
-close(c);
+closesocket(c);
 }
 
 void tcp_start_incoming_migration(const char *host_port, Error **errp)
-- 
1.7.12.1





[Qemu-devel] [PATCH 04/12] migration: replace qemu_stdio_fd with qemu_get_fd

2012-11-02 Thread Paolo Bonzini
Reviewed-by: Orit Wasserman 
Signed-off-by: Paolo Bonzini 
---
 migration-exec.c |  4 ++--
 migration-fd.c   |  2 +-
 qemu-file.h  |  1 -
 savevm.c | 11 ---
 4 file modificati, 3 inserzioni(+), 15 rimozioni(-)

diff --git a/migration-exec.c b/migration-exec.c
index 519af57..452bf07 100644
--- a/migration-exec.c
+++ b/migration-exec.c
@@ -88,7 +88,7 @@ static void exec_accept_incoming_migration(void *opaque)
 QEMUFile *f = opaque;
 
 process_incoming_migration(f);
-qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
+qemu_set_fd_handler2(qemu_get_fd(f), NULL, NULL, NULL, NULL);
 qemu_fclose(f);
 }
 
@@ -103,6 +103,6 @@ void exec_start_incoming_migration(const char *command, 
Error **errp)
 return;
 }
 
-qemu_set_fd_handler2(qemu_stdio_fd(f), NULL,
+qemu_set_fd_handler2(qemu_get_fd(f), NULL,
 exec_accept_incoming_migration, NULL, f);
 }
diff --git a/migration-fd.c b/migration-fd.c
index ce6932d..b47b222 100644
--- a/migration-fd.c
+++ b/migration-fd.c
@@ -93,7 +93,7 @@ static void fd_accept_incoming_migration(void *opaque)
 QEMUFile *f = opaque;
 
 process_incoming_migration(f);
-qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
+qemu_set_fd_handler2(qemu_get_fd(f), NULL, NULL, NULL, NULL);
 qemu_fclose(f);
 }
 
diff --git a/qemu-file.h b/qemu-file.h
index d552f5d..d64bdbb 100644
--- a/qemu-file.h
+++ b/qemu-file.h
@@ -80,7 +80,6 @@ QEMUFile *qemu_fopen_socket(int fd);
 QEMUFile *qemu_popen(FILE *popen_file, const char *mode);
 QEMUFile *qemu_popen_cmd(const char *command, const char *mode);
 int qemu_get_fd(QEMUFile *f);
-int qemu_stdio_fd(QEMUFile *f);
 int qemu_fclose(QEMUFile *f);
 void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
 void qemu_put_byte(QEMUFile *f, int v);
diff --git a/savevm.c b/savevm.c
index a58fe9a..0ab1ad4 100644
--- a/savevm.c
+++ b/savevm.c
@@ -311,17 +311,6 @@ QEMUFile *qemu_popen_cmd(const char *command, const char 
*mode)
 return qemu_popen(popen_file, mode);
 }
 
-int qemu_stdio_fd(QEMUFile *f)
-{
-QEMUFileStdio *p;
-int fd;
-
-p = (QEMUFileStdio *)f->opaque;
-fd = fileno(p->stdio_file);
-
-return fd;
-}
-
 static const QEMUFileOps stdio_file_read_ops = {
 .get_fd = stdio_get_fd,
 .get_buffer = stdio_get_buffer,
-- 
1.7.12.1





[Qemu-devel] [PATCH 2/2] x86/cpu: add new Opteron CPU model

2012-11-02 Thread Boris Ostrovsky
From: Andre Przywara 

Add a new base CPU model called Opteron_G5 to model the latest
Opteron CPUs. This increases the model value and model numbers and
adds TBM, F16C and FMA over the latest G4 model.

Signed-off-by: Andre Przywara 
Signed-off-by: Boris Ostrovsky 
---
 target-i386/cpu.c |   32 
 1 file changed, 32 insertions(+)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index ec9b71f..332f9e8 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -745,6 +745,38 @@ static x86_def_t builtin_x86_defs[] = {
 .xlevel = 0x801A,
 .model_id = "AMD Opteron 62xx class CPU",
 },
+{
+.name = "Opteron_G5",
+.level = 0xd,
+.vendor1 = CPUID_VENDOR_AMD_1,
+.vendor2 = CPUID_VENDOR_AMD_2,
+.vendor3 = CPUID_VENDOR_AMD_3,
+.family = 21,
+.model = 2,
+.stepping = 0,
+.features = CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+ CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
+ CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
+ CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
+ CPUID_DE | CPUID_FP87,
+.ext_features = CPUID_EXT_F16C | CPUID_EXT_AVX | CPUID_EXT_XSAVE |
+ CPUID_EXT_AES | CPUID_EXT_POPCNT | CPUID_EXT_SSE42 |
+ CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_FMA |
+ CPUID_EXT_SSSE3 | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3,
+.ext2_features = CPUID_EXT2_LM | CPUID_EXT2_RDTSCP |
+ CPUID_EXT2_PDPE1GB | CPUID_EXT2_FXSR | CPUID_EXT2_MMX |
+ CPUID_EXT2_NX | CPUID_EXT2_PSE36 | CPUID_EXT2_PAT |
+ CPUID_EXT2_CMOV | CPUID_EXT2_MCA | CPUID_EXT2_PGE |
+ CPUID_EXT2_MTRR | CPUID_EXT2_SYSCALL | CPUID_EXT2_APIC |
+ CPUID_EXT2_CX8 | CPUID_EXT2_MCE | CPUID_EXT2_PAE | CPUID_EXT2_MSR 
|
+ CPUID_EXT2_TSC | CPUID_EXT2_PSE | CPUID_EXT2_DE | CPUID_EXT2_FPU,
+.ext3_features = CPUID_EXT3_TBM | CPUID_EXT3_FMA4 | CPUID_EXT3_XOP |
+ CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_MISALIGNSSE |
+ CPUID_EXT3_SSE4A | CPUID_EXT3_ABM | CPUID_EXT3_SVM |
+ CPUID_EXT3_LAHF_LM,
+.xlevel = 0x801A,
+.model_id = "AMD Opteron 63xx class CPU",
+},
 };
 
 static int cpu_x86_fill_model_id(char *str)
-- 
1.7.10.4




[Qemu-devel] [PATCH 1/2] x86/cpu: name new CPUID bits

2012-11-02 Thread Boris Ostrovsky
From: Andre Przywara 

Update QEMU's knowledge of CPUID bit names. This allows to
enable/disable those new features on QEMU's command line when
using KVM and prepares future feature enablement in QEMU.

This adds F16C, RDRAND, LWP, TBM, TopoExt, PerfCtr_Core, PerfCtr_NB,
FSGSBASE, BMI1, AVX2, BMI2, ERMS, InvPCID, RTM, RDSeed and ADX.

Sources where the AMD BKDG for Family 15h/Model 10h and the Linux kernel
for the leaf 7 bits.

Signed-off-by: Andre Przywara 
Signed-off-by: Boris Ostrovsky 
---
 target-i386/cpu.c |   16 
 target-i386/cpu.h |   21 +
 2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index d4f2e65..ec9b71f 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -59,7 +59,7 @@ static const char *ext_feature_name[] = {
 NULL, "pcid", "dca", "sse4.1|sse4_1",
 "sse4.2|sse4_2", "x2apic", "movbe", "popcnt",
 "tsc-deadline", "aes", "xsave", "osxsave",
-"avx", NULL, NULL, "hypervisor",
+"avx", "f16c", "rdrand", "hypervisor",
 };
 /* Feature names that are already defined on feature_name[] but are set on
  * CPUID[8000_0001].EDX on AMD CPUs don't have their names on
@@ -80,10 +80,10 @@ static const char *ext3_feature_name[] = {
 "lahf_lm" /* AMD LahfSahf */, "cmp_legacy", "svm", "extapic" /* AMD 
ExtApicSpace */,
 "cr8legacy" /* AMD AltMovCr8 */, "abm", "sse4a", "misalignsse",
 "3dnowprefetch", "osvw", "ibs", "xop",
-"skinit", "wdt", NULL, NULL,
-"fma4", NULL, "cvt16", "nodeid_msr",
-NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
+"skinit", "wdt", NULL, "lwp",
+"fma4", "tce", NULL, "nodeid_msr",
+NULL, "tbm", "topoext", "perfctr_core",
+"perfctr_nb", NULL, NULL, NULL,
 NULL, NULL, NULL, NULL,
 };
 
@@ -106,9 +106,9 @@ static const char *svm_feature_name[] = {
 };
 
 static const char *cpuid_7_0_ebx_feature_name[] = {
-NULL, NULL, NULL, NULL, NULL, NULL, NULL, "smep",
-NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL, "smap", NULL, NULL, NULL,
+"fsgsbase", NULL, NULL, "bmi1", "hle", "avx2", NULL, "smep",
+"bmi2", "erms", "invpcid", "rtm", NULL, NULL, NULL, NULL,
+NULL, NULL, "rdseed", "adx", "smap", NULL, NULL, NULL,
 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 };
 
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index de33303..a597e03 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -403,6 +403,7 @@
 #define CPUID_EXT_TM2  (1 << 8)
 #define CPUID_EXT_SSSE3(1 << 9)
 #define CPUID_EXT_CID  (1 << 10)
+#define CPUID_EXT_FMA  (1 << 12)
 #define CPUID_EXT_CX16 (1 << 13)
 #define CPUID_EXT_XTPR (1 << 14)
 #define CPUID_EXT_PDCM (1 << 15)
@@ -417,6 +418,8 @@
 #define CPUID_EXT_XSAVE(1 << 26)
 #define CPUID_EXT_OSXSAVE  (1 << 27)
 #define CPUID_EXT_AVX  (1 << 28)
+#define CPUID_EXT_F16C (1 << 29)
+#define CPUID_EXT_RDRAND   (1 << 30)
 #define CPUID_EXT_HYPERVISOR  (1 << 31)
 
 #define CPUID_EXT2_FPU (1 << 0)
@@ -472,7 +475,15 @@
 #define CPUID_EXT3_IBS (1 << 10)
 #define CPUID_EXT3_XOP (1 << 11)
 #define CPUID_EXT3_SKINIT  (1 << 12)
+#define CPUID_EXT3_WDT (1 << 13)
+#define CPUID_EXT3_LWP (1 << 15)
 #define CPUID_EXT3_FMA4(1 << 16)
+#define CPUID_EXT3_TCE (1 << 17)
+#define CPUID_EXT3_NODEID  (1 << 19)
+#define CPUID_EXT3_TBM (1 << 21)
+#define CPUID_EXT3_TOPOEXT (1 << 22)
+#define CPUID_EXT3_PERFCORE (1 << 23)
+#define CPUID_EXT3_PERFNB  (1 << 24)
 
 #define CPUID_SVM_NPT  (1 << 0)
 #define CPUID_SVM_LBRV (1 << 1)
@@ -485,7 +496,17 @@
 #define CPUID_SVM_PAUSEFILTER  (1 << 10)
 #define CPUID_SVM_PFTHRESHOLD  (1 << 12)
 
+#define CPUID_7_0_EBX_FSGSBASE (1 << 0)
+#define CPUID_7_0_EBX_BMI1 (1 << 3)
+#define CPUID_7_0_EBX_HLE  (1 << 4)
+#define CPUID_7_0_EBX_AVX2 (1 << 5)
 #define CPUID_7_0_EBX_SMEP (1 << 7)
+#define CPUID_7_0_EBX_BMI2 (1 << 8)
+#define CPUID_7_0_EBX_ERMS (1 << 9)
+#define CPUID_7_0_EBX_INVPCID  (1 << 10)
+#define CPUID_7_0_EBX_RTM  (1 << 11)
+#define CPUID_7_0_EBX_RDSEED   (1 << 18)
+#define CPUID_7_0_EBX_ADX  (1 << 19)
 #define CPUID_7_0_EBX_SMAP (1 << 20)
 
 #define CPUID_VENDOR_INTEL_1 0x756e6547 /* "Genu" */
-- 
1.7.10.4




[Qemu-devel] [PATCH 0/2] Add support for new Opteron CPU model

2012-11-02 Thread Boris Ostrovsky
From: Andre Przywara 

Two patches to provide support for new Opteron processors. The first
patch was submitted earlier 
(http://lists.nongnu.org/archive/html/qemu-devel/2012-10/msg03058.html)
and may have already been applied.

Andre Przywara (2):
  x86/cpu: name new CPUID bits
  x86/cpu: add new Opteron CPU model

 target-i386/cpu.c |   48 
 target-i386/cpu.h |   21 +
 2 files changed, 61 insertions(+), 8 deletions(-)

-- 
1.7.10.4




[Qemu-devel] [PATCH 02/12] migration: consolidate QEMUFile methods in a single QEMUFileOps struct

2012-11-02 Thread Paolo Bonzini
Reviewed-by: Orit Wasserman 
Signed-off-by: Paolo Bonzini 
---
 buffered_file.c |  13 ---
 qemu-file.h |  16 +
 savevm.c| 108 +++-
 3 file modificati, 79 inserzioni(+), 58 rimozioni(-)

diff --git a/buffered_file.c b/buffered_file.c
index ed92df1..a5c0b12 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -234,6 +234,14 @@ static void buffered_rate_tick(void *opaque)
 buffered_put_buffer(s, NULL, 0, 0);
 }
 
+static const QEMUFileOps buffered_file_ops = {
+.put_buffer = buffered_put_buffer,
+.close =  buffered_close,
+.rate_limit = buffered_rate_limit,
+.get_rate_limit = buffered_get_rate_limit,
+.set_rate_limit = buffered_set_rate_limit,
+};
+
 QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state)
 {
 QEMUFileBuffered *s;
@@ -243,10 +251,7 @@ QEMUFile *qemu_fopen_ops_buffered(MigrationState 
*migration_state)
 s->migration_state = migration_state;
 s->xfer_limit = migration_state->bandwidth_limit / 10;
 
-s->file = qemu_fopen_ops(s, buffered_put_buffer, NULL,
- buffered_close, buffered_rate_limit,
- buffered_set_rate_limit,
-buffered_get_rate_limit);
+s->file = qemu_fopen_ops(s, &buffered_file_ops);
 
 s->timer = qemu_new_timer_ms(rt_clock, buffered_rate_tick, s);
 
diff --git a/qemu-file.h b/qemu-file.h
index 9c8985b..c89e8e0 100644
--- a/qemu-file.h
+++ b/qemu-file.h
@@ -59,12 +59,16 @@ typedef int (QEMUFileRateLimit)(void *opaque);
 typedef int64_t (QEMUFileSetRateLimit)(void *opaque, int64_t new_rate);
 typedef int64_t (QEMUFileGetRateLimit)(void *opaque);
 
-QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,
- QEMUFileGetBufferFunc *get_buffer,
- QEMUFileCloseFunc *close,
- QEMUFileRateLimit *rate_limit,
- QEMUFileSetRateLimit *set_rate_limit,
- QEMUFileGetRateLimit *get_rate_limit);
+typedef struct QEMUFileOps {
+QEMUFilePutBufferFunc *put_buffer;
+QEMUFileGetBufferFunc *get_buffer;
+QEMUFileCloseFunc *close;
+QEMUFileRateLimit *rate_limit;
+QEMUFileSetRateLimit *set_rate_limit;
+QEMUFileGetRateLimit *get_rate_limit;
+} QEMUFileOps;
+
+QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops);
 QEMUFile *qemu_fopen(const char *filename, const char *mode);
 QEMUFile *qemu_fdopen(int fd, const char *mode);
 QEMUFile *qemu_fopen_socket(int fd);
diff --git a/savevm.c b/savevm.c
index cfcf918..a4158ec 100644
--- a/savevm.c
+++ b/savevm.c
@@ -163,12 +163,7 @@ void qemu_announce_self(void)
 #define IO_BUF_SIZE 32768
 
 struct QEMUFile {
-QEMUFilePutBufferFunc *put_buffer;
-QEMUFileGetBufferFunc *get_buffer;
-QEMUFileCloseFunc *close;
-QEMUFileRateLimit *rate_limit;
-QEMUFileSetRateLimit *set_rate_limit;
-QEMUFileGetRateLimit *get_rate_limit;
+const QEMUFileOps *ops;
 void *opaque;
 int is_write;
 
@@ -257,6 +252,16 @@ static int stdio_fclose(void *opaque)
 return ret;
 }
 
+static const QEMUFileOps stdio_pipe_read_ops = {
+.get_buffer = stdio_get_buffer,
+.close =  stdio_pclose
+};
+
+static const QEMUFileOps stdio_pipe_write_ops = {
+.put_buffer = stdio_put_buffer,
+.close =  stdio_pclose
+};
+
 QEMUFile *qemu_popen(FILE *stdio_file, const char *mode)
 {
 QEMUFileStdio *s;
@@ -271,11 +276,9 @@ QEMUFile *qemu_popen(FILE *stdio_file, const char *mode)
 s->stdio_file = stdio_file;
 
 if(mode[0] == 'r') {
-s->file = qemu_fopen_ops(s, NULL, stdio_get_buffer, stdio_pclose, 
-NULL, NULL, NULL);
+s->file = qemu_fopen_ops(s, &stdio_pipe_read_ops);
 } else {
-s->file = qemu_fopen_ops(s, stdio_put_buffer, NULL, stdio_pclose, 
-NULL, NULL, NULL);
+s->file = qemu_fopen_ops(s, &stdio_pipe_write_ops);
 }
 return s->file;
 }
@@ -303,6 +306,16 @@ int qemu_stdio_fd(QEMUFile *f)
 return fd;
 }
 
+static const QEMUFileOps stdio_file_read_ops = {
+.get_buffer = stdio_get_buffer,
+.close =  stdio_fclose
+};
+
+static const QEMUFileOps stdio_file_write_ops = {
+.put_buffer = stdio_put_buffer,
+.close =  stdio_fclose
+};
+
 QEMUFile *qemu_fdopen(int fd, const char *mode)
 {
 QEMUFileStdio *s;
@@ -320,11 +333,9 @@ QEMUFile *qemu_fdopen(int fd, const char *mode)
 goto fail;
 
 if(mode[0] == 'r') {
-s->file = qemu_fopen_ops(s, NULL, stdio_get_buffer, stdio_fclose, 
-NULL, NULL, NULL);
+s->file = qemu_fopen_ops(s, &stdio_file_read_ops);
 } else {
-s->file = qemu_fopen_ops(s, stdio_put_buffer, NULL, stdio_fclose, 
-NULL, NULL, NULL);
+s->file = qemu_fopen_ops(s, &stdio_file_write_ops);
 }
 return s->

Re: [Qemu-devel] Fwd: buildbot failure in qemu on openbsd-default

2012-11-02 Thread Paolo Bonzini
Il 02/11/2012 17:22, Anthony Liguori ha scritto:
> 
> I think this one is you Paolo...

Yup, 5-patch series already on the list and smoke-tested by Peter on Mac
OS X (which has the same problem).

Paolo



[Qemu-devel] [PATCH 08/12] migration: xxx_close will only be called once

2012-11-02 Thread Paolo Bonzini
No need to test s->fd again, it is tested in the caller.

Reviewed-by: Orit Wasserman 
Signed-off-by: Paolo Bonzini 
---
 migration-exec.c | 14 ++
 migration-fd.c   | 33 +++--
 migration-tcp.c  |  7 ++-
 migration-unix.c |  7 ++-
 4 file modificati, 25 inserzioni(+), 36 rimozioni(-)

diff --git a/migration-exec.c b/migration-exec.c
index 014c60f..2ce7770 100644
--- a/migration-exec.c
+++ b/migration-exec.c
@@ -48,14 +48,12 @@ static int exec_close(MigrationState *s)
 {
 int ret = 0;
 DPRINTF("exec_close\n");
-if (s->opaque) {
-ret = qemu_fclose(s->opaque);
-s->opaque = NULL;
-s->fd = -1;
-if (ret >= 0 && !(WIFEXITED(ret) && WEXITSTATUS(ret) == 0)) {
-/* close succeeded, but non-zero exit code: */
-ret = -EIO; /* fake errno value */
-}
+ret = qemu_fclose(s->opaque);
+s->opaque = NULL;
+s->fd = -1;
+if (ret >= 0 && !(WIFEXITED(ret) && WEXITSTATUS(ret) == 0)) {
+/* close succeeded, but non-zero exit code: */
+ret = -EIO; /* fake errno value */
 }
 return ret;
 }
diff --git a/migration-fd.c b/migration-fd.c
index a4cd83f..c678b23 100644
--- a/migration-fd.c
+++ b/migration-fd.c
@@ -48,29 +48,26 @@ static int fd_close(MigrationState *s)
 int ret;
 
 DPRINTF("fd_close\n");
-if (s->fd != -1) {
-ret = fstat(s->fd, &st);
-if (ret == 0 && S_ISREG(st.st_mode)) {
-/*
- * If the file handle is a regular file make sure the
- * data is flushed to disk before signaling success.
- */
-ret = fsync(s->fd);
-if (ret != 0) {
-ret = -errno;
-perror("migration-fd: fsync");
-return ret;
-}
-}
-ret = close(s->fd);
-s->fd = -1;
+ret = fstat(s->fd, &st);
+if (ret == 0 && S_ISREG(st.st_mode)) {
+/*
+ * If the file handle is a regular file make sure the
+ * data is flushed to disk before signaling success.
+ */
+ret = fsync(s->fd);
 if (ret != 0) {
 ret = -errno;
-perror("migration-fd: close");
+perror("migration-fd: fsync");
 return ret;
 }
 }
-return 0;
+ret = close(s->fd);
+s->fd = -1;
+if (ret != 0) {
+ret = -errno;
+perror("migration-fd: close");
+}
+return ret;
 }
 
 void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error 
**errp)
diff --git a/migration-tcp.c b/migration-tcp.c
index 1a12f17..bb27ce8 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -44,11 +44,8 @@ static int tcp_close(MigrationState *s)
 {
 int r = 0;
 DPRINTF("tcp_close\n");
-if (s->fd != -1) {
-if (closesocket(s->fd) < 0) {
-r = -errno;
-}
-s->fd = -1;
+if (closesocket(s->fd) < 0) {
+r = -socket_error();
 }
 return r;
 }
diff --git a/migration-unix.c b/migration-unix.c
index 5dc49cd..9b5521e 100644
--- a/migration-unix.c
+++ b/migration-unix.c
@@ -44,11 +44,8 @@ static int unix_close(MigrationState *s)
 {
 int r = 0;
 DPRINTF("unix_close\n");
-if (s->fd != -1) {
-if (close(s->fd) < 0) {
-r = -errno;
-}
-s->fd = -1;
+if (close(s->fd) < 0) {
+r = -errno;
 }
 return r;
 }
-- 
1.7.12.1





[Qemu-devel] [PATCH 06/12] migration: use migrate_fd_close in migrate_fd_cleanup

2012-11-02 Thread Paolo Bonzini
migrate_fd_cleanup will usually close the file descriptor via
buffered_file_close's call to migrate_fd_close.  However, in the case
of s->file == NULL it is "inlining" migrate_fd_close (almost: there is a
direct close() instead of using s->close(s)).  To fix the inconsistency
and clean up the code, allow multiple calls to migrate_fd_close and use
the function in migrate_fd_cleanup.

Signed-off-by: Paolo Bonzini 
---
 migration.c | 19 ---
 1 file modificato, 8 inserzioni(+), 11 rimozioni(-)

diff --git a/migration.c b/migration.c
index 300ab75..a63596f 100644
--- a/migration.c
+++ b/migration.c
@@ -243,21 +243,13 @@ static int migrate_fd_cleanup(MigrationState *s)
 {
 int ret = 0;
 
-if (s->fd != -1) {
-qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
-}
-
 if (s->file) {
 DPRINTF("closing file\n");
 ret = qemu_fclose(s->file);
 s->file = NULL;
 }
 
-if (s->fd != -1) {
-close(s->fd);
-s->fd = -1;
-}
-
+migrate_fd_close(s);
 return ret;
 }
 
@@ -393,8 +385,13 @@ int migrate_fd_wait_for_unfreeze(MigrationState *s)
 
 int migrate_fd_close(MigrationState *s)
 {
-qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
-return s->close(s);
+int rc = 0;
+if (s->fd != -1) {
+qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
+rc = s->close(s);
+s->fd = -1;
+}
+return rc;
 }
 
 void add_migration_state_change_notifier(Notifier *notify)
-- 
1.7.12.1





[Qemu-devel] [PULL 00/12] Incoming migration coroutine

2012-11-02 Thread Paolo Bonzini
Anthony,

The following changes since commit 4ba79505f43bd0ace35c3fe42197eb02e7e0478e:

  Merge remote-tracking branch 'kraxel/pixman.v3' into staging (2012-11-01 
11:14:39 -0500)

are available in the git repository at:


  git://github.com/bonzini/qemu.git migr-coroutine

for you to fetch changes up to 82a4da79fd6c108400637143f8439c2364bdb21e:

  migration: move process_incoming_migration to a coroutine (2012-11-02 
18:35:08 +0100)

With these patches, the monitor and the NBD server are responsive during
migration.

The first ten patches are just cleanups, generalizing some parts of
QEMUFile and improving the way migration sockets are closed.

The last two actually implement the feature.  They are the opposite
change of the nonblocking->blocking change that you implemented for the
migration thread.  However, the change is much simpler because we have
no timers, and because of the use of coroutines.

Without coroutines (and as in non-threaded migration), you have
to proceed in two steps: first collect data in a buffer, then
write it.  This lets you handle EAGAIN only at precise points in
buffered_flush/buffered_put_buffer, so that you can restart writing
in migrate_fd_put_notify.  This "checkpointing" is the reason why
QEMUFileBuffered exists.  With coroutines, you can just stop whenever
you want with qemu_coroutine_yield.  As soon as select tells you that
you can read, you'll re-enter directly in qemu_get_buffer, read more
data and pass it to the loading routines.

Paolo

Paolo Bonzini (12):
  migration: unify stdio-based QEMUFile operations
  migration: consolidate QEMUFile methods in a single QEMUFileOps struct
  migration: add qemu_get_fd
  migration: replace qemu_stdio_fd with qemu_get_fd
  migration: clean up server sockets and handlers before invoking 
process_incoming_migration
  migration: use migrate_fd_close in migrate_fd_cleanup
  migration: use closesocket, not close
  migration: xxx_close will only be called once
  migration: close socket QEMUFile from socket_close
  migration: move qemu_fclose to process_incoming_migration
  migration: handle EAGAIN while reading QEMUFile
  migration: move process_incoming_migration to a coroutine

 buffered_file.c  |  21 +--
 migration-exec.c |  19 +++---
 migration-fd.c   |  36 +--
 migration-tcp.c  |  19 +++---
 migration-unix.c |  17 +++--
 migration.c  |  46 ++
 qemu-file.h  |  23 ---
 savevm.c | 188 ---
 8 file modificati, 215 inserzioni(+), 154 rimozioni(-)
-- 
1.7.12.1




[Qemu-devel] [PATCH] target-i386: cpu: fix --disable-kvm compilation

2012-11-02 Thread Andreas Färber
From: Eduardo Habkost 

This fixes the following:
  target-i386/cpu.o: In function `kvm_cpu_fill_host':
  target-i386/cpu.c:783: undefined reference to `kvm_state'

I didn't notice the problem before because GCC was optimizing the entire
kvm_cpu_fill_host() function out (because all calls are conditional on
kvm_enabled()).

* cpu_x86_fill_model_id() is used only if CONFIG_KVM is set, so #ifdef it
  entirely to avoid compiler warnings.

* kvm_cpu_fill_host() should be called only if KVM is enabled, so
  use #ifdef CONFIG_KVM around the entire function body.

Reported-by: Andreas Färber 
Signed-off-by: Eduardo Habkost 
Signed-off-by: Andreas Färber 
---
 target-i386/cpu.c |4 
 1 Datei geändert, 4 Zeilen hinzugefügt(+)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index c46286a..e1db639 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -758,6 +758,7 @@ static x86_def_t builtin_x86_defs[] = {
 },
 };
 
+#ifdef CONFIG_KVM
 static int cpu_x86_fill_model_id(char *str)
 {
 uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
@@ -772,6 +773,7 @@ static int cpu_x86_fill_model_id(char *str)
 }
 return 0;
 }
+#endif
 
 /* Fill a x86_def_t struct with information about the host CPU, and
  * the CPU features supported by the host hardware + host kernel
@@ -780,6 +782,7 @@ static int cpu_x86_fill_model_id(char *str)
  */
 static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
 {
+#ifdef CONFIG_KVM
 KVMState *s = kvm_state;
 uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
 
@@ -838,6 +841,7 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
  * unsupported ones later.
  */
 x86_cpu_def->svm_features = -1;
+#endif /* CONFIG_KVM */
 }
 
 static int unavailable_host_feature(struct model_features_t *f, uint32_t mask)
-- 
1.7.10.4




[Qemu-devel] [PULL buildfix] QOM CPUState patch queue 2012-11-02

2012-11-02 Thread Andreas Färber
Hello,

Here's a build fix for {i386,x86_64}-linux-user. Please pull.

Regards,
Andreas


The following changes since commit 4ba79505f43bd0ace35c3fe42197eb02e7e0478e:

  Merge remote-tracking branch 'kraxel/pixman.v3' into staging (2012-11-01 
11:14:39 -0500)

are available in the git repository at:


  git://github.com/afaerber/qemu-cpu.git qom-cpu

for you to fetch changes up to e4ab0d6b0d1118a90238d8194eedb91aab15ebe1:

  target-i386: cpu: fix --disable-kvm compilation (2012-11-02 17:55:29 +0100)


Eduardo Habkost (1):
  target-i386: cpu: fix --disable-kvm compilation

 target-i386/cpu.c |4 
 1 Datei geändert, 4 Zeilen hinzugefügt(+)



Re: [Qemu-devel] [PATCH] target-i386: cpu: fix --disable-kvm compilation

2012-11-02 Thread Andreas Färber
Am 02.11.2012 17:25, schrieb Eduardo Habkost:
> This fixes the following:
>   target-i386/cpu.o: In function `kvm_cpu_fill_host':
>   target-i386/cpu.c:783: undefined reference to `kvm_state'
> 
> I didn't notice the problem before because GCC was optimizing the entire
> kvm_cpu_fill_host() function out (because all calls are conditional on
> kvm_enabled()).
> 
> * cpu_x86_fill_model_id() is used only if CONFIG_KVM is set, so #ifdef it
>   entirely to avoid compiler warnings.
> 
> * kvm_cpu_fill_host() should be called only if KVM is enabled, so
>   use #ifdef CONFIG_KVM around the entire function body.
> 
> Reported-by: Andreas Färber 
> Signed-off-by: Eduardo Habkost 

Acked-by: Andreas Färber 

If no one objects to this solution, unless Marcelo or Avi beat me, I'll
send out an urgent pull request as requested by Anthony.

Thanks,
Andreas

> ---
>  target-i386/cpu.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index c46286a..e1db639 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -758,6 +758,7 @@ static x86_def_t builtin_x86_defs[] = {
>  },
>  };
>  
> +#ifdef CONFIG_KVM
>  static int cpu_x86_fill_model_id(char *str)
>  {
>  uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
> @@ -772,6 +773,7 @@ static int cpu_x86_fill_model_id(char *str)
>  }
>  return 0;
>  }
> +#endif
>  
>  /* Fill a x86_def_t struct with information about the host CPU, and
>   * the CPU features supported by the host hardware + host kernel
> @@ -780,6 +782,7 @@ static int cpu_x86_fill_model_id(char *str)
>   */
>  static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
>  {
> +#ifdef CONFIG_KVM
>  KVMState *s = kvm_state;
>  uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
>  
> @@ -838,6 +841,7 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
>   * unsupported ones later.
>   */
>  x86_cpu_def->svm_features = -1;
> +#endif /* CONFIG_KVM */
>  }
>  
>  static int unavailable_host_feature(struct model_features_t *f, uint32_t 
> mask)
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PULL 00/22] console cleanups & pixman rendering

2012-11-02 Thread Andreas Färber
Am 02.11.2012 17:14, schrieb Andreas Färber:
> Am 01.11.2012 20:33, schrieb Anthony Liguori:
>> Gerd Hoffmann  writes:
>>
>>>   Hi,
>>>
>>> Sitting on these too long already.  Series has been on the list a while
>>> back, only splitted into two parts (separate "console cleanups" series
>>> carrying patches 1-8).  Patch 11 was updated according to Paolos
>>> suggestion, otherwise the patches are unmodified.
>>>
>>> please pull,
>>>   Gerd
>>
>> Pulled. Thanks.
> 
> Getting this on SLES 11 SP2 s390x (pixman 0.16.0):
> 
> cc1: warnings being treated as errors
> In file included from /home/andreas/qemu-s390/qemu-pixman.h:4,
>  from /home/andreas/qemu-s390/console.h:5,
>  from /home/andreas/qemu-s390/qemu-timer.c:28:
> /usr/include/pixman-1/pixman.h:225: error: redundant redeclaration of
> ‘pixman_transform_from_pixman_f_transform’
> /usr/include/pixman-1/pixman.h:221: error: previous declaration of
> ‘pixman_transform_from_pixman_f_transform’ was here
> make: *** [qemu-timer.o] Fehler 1
> make: *** Warte auf noch nicht beendete Prozesse...
> 
> Any idea how to resolve?

So, it seems that our pixman 0.16.0 header has a genuine redundant
declaration, not influenced by qemu-pixman.h. I worked around it by
manually changing -Wredundant-decl to -Wno-redundant-decl in configure,
similar to what some FreeBSD versions needed. Suggestions for a real
warnings-fix or configure-detection of incompatible headers appreciated!

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH] target-i386: cpu: fix --disable-kvm compilation

2012-11-02 Thread Eduardo Habkost
This fixes the following:
  target-i386/cpu.o: In function `kvm_cpu_fill_host':
  target-i386/cpu.c:783: undefined reference to `kvm_state'

I didn't notice the problem before because GCC was optimizing the entire
kvm_cpu_fill_host() function out (because all calls are conditional on
kvm_enabled()).

* cpu_x86_fill_model_id() is used only if CONFIG_KVM is set, so #ifdef it
  entirely to avoid compiler warnings.

* kvm_cpu_fill_host() should be called only if KVM is enabled, so
  use #ifdef CONFIG_KVM around the entire function body.

Reported-by: Andreas Färber 
Signed-off-by: Eduardo Habkost 
---
 target-i386/cpu.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index c46286a..e1db639 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -758,6 +758,7 @@ static x86_def_t builtin_x86_defs[] = {
 },
 };
 
+#ifdef CONFIG_KVM
 static int cpu_x86_fill_model_id(char *str)
 {
 uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
@@ -772,6 +773,7 @@ static int cpu_x86_fill_model_id(char *str)
 }
 return 0;
 }
+#endif
 
 /* Fill a x86_def_t struct with information about the host CPU, and
  * the CPU features supported by the host hardware + host kernel
@@ -780,6 +782,7 @@ static int cpu_x86_fill_model_id(char *str)
  */
 static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
 {
+#ifdef CONFIG_KVM
 KVMState *s = kvm_state;
 uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
 
@@ -838,6 +841,7 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
  * unsupported ones later.
  */
 x86_cpu_def->svm_features = -1;
+#endif /* CONFIG_KVM */
 }
 
 static int unavailable_host_feature(struct model_features_t *f, uint32_t mask)
-- 
1.7.11.7




Re: [Qemu-devel] Fwd: buildbot failure in qemu on openbsd-default

2012-11-02 Thread Anthony Liguori

I think this one is you Paolo...

Regards,

ANthony Liguori

Gerd Hoffmann  writes:

>  Original Message 
> Subject: buildbot failure in qemu on openbsd-default
> Date: Thu, 01 Nov 2012 21:12:01 +0100
> From: build...@spunk.home.kraxel.org
> To: kraxel...@gmail.com
>
> The Buildbot has detected a failed build on builder openbsd-default
> while building qemu.
> Full details are available at:
>  http://www.kraxel.org/bb/builders/openbsd-default/builds/866
>
> Buildbot URL: http://www.kraxel.org/bb/
>
> Buildslave for this Build: openbsd
>
> Build Reason: scheduler
> Build Source Stamp: [branch master] 4ba79505f43bd0ace35c3fe42197eb02e7e0478e
> Blamelist: Andreas Färber ,Anthony Liguori
> ,Dmitry Fleytman ,Don Slutz
> ,Eduardo Habkost ,Gabriel L.
> Somlo ,Gerd Hoffmann ,Igor Mammedov
> ,Jan Kiszka ,Lei Li
> ,Marcelo Tosatti ,Paolo
> Bonzini ,Peter Maydell
> ,Stefan Hajnoczi 
>
> BUILD FAILED: failed compile
>
> sincerely,
>  -The Buildbot
>
>
> == log tail ==
>   GEN   qapi-visit.c
>   CCqapi-visit.o
>   CCqapi/qapi-visit-core.o
>   CCqapi/qapi-dealloc-visitor.o
>   CCqapi/qmp-input-visitor.o
>   CCqapi/qmp-output-visitor.o
>   CCqapi/qmp-registry.o
>   CCqapi/qmp-dispatch.o
>   CCqapi/string-input-visitor.o
>   CCqapi/string-output-visitor.o
>   CCqint.o
>   CCqstring.o
>   CCqdict.o
>   CCqlist.o
>   CCqfloat.o
>   CCqbool.o
>   CCqjson.o
>   CCjson-lexer.o
>   CCjson-streamer.o
>   CCjson-parser.o
>   CCqerror.o
>   CCerror.o
>   CCqemu-error.o
>   LINK  qemu-ga
> /usr/local/lib/libglib-2.0.so.2992.0: warning: vsprintf() is often
> misused, please use vsnprintf()
> /usr/local/lib/libglib-2.0.so.2992.0: warning: stpcpy() is dangerous GNU
> crap; don't use it
> /usr/local/lib/libglib-2.0.so.2992.0: warning: strcpy() is almost always
> misused, please use strlcpy()
> /usr/local/lib/libglib-2.0.so.2992.0: warning: sprintf() is often
> misused, please use snprintf()
> qemu-thread-posix.o(.text+0x3ea): In function `qemu_sem_timedwait':
> : undefined reference to `sem_timedwait'
> collect2: ld returned 1 exit status
> gmake: *** [qemu-ga] Error 1
>
> == full log ==
> http://www.kraxel.org/bb/builders/openbsd-default/builds/866/steps/compile/logs/stdio



Re: [Qemu-devel] [PATCH] ui/cocoa.m: Update to new DisplayChangeListener member names

2012-11-02 Thread Anthony Liguori
Andreas Färber  writes:

> Hi,
>
> Am 02.11.2012 16:41, schrieb Gerd Hoffmann:
>>> (I have a philosophical preference for compile fixes being applied
>>> directly and quickly to master but my opinion on that matter is
>>> not particularly significant :-))
>> 
>> /me too.  Build fixes should go in on the fast track.  First because a
>> broken build is annonying.  Second because buildbots are less useful if
>> builds are broken for longer periods.
>
> Fine with me, less work. We should cc a maintainer then. ;)
>
>> One of the reasons I didn't notice the xenfb breakage was because the
>> fedora build is broken for other reasons, so the buildbot doesn't came
>> to the point where it tries to build xenfb.c and figures it doesn't.
>> 
>> Should we maybe agree on a special buildfix patch subject tag, so
>> maintainers can easily filter and prioritize them?
>
> I used [PATCH buildfix] or so in the past.

Not all build errors are created equal.

It's impossible for me to build cocoa support without physical Apple
hardware.

In this case, the cocoa maintainer (Andreas) should send an urgent pull
request to ensure the patch is properly tested.

I'm applying right now, so no worries this time, but if you are a
submaintainer, if there is something you consider urgent, you should
send a pull request.

Regards,

Anthony Liguori

>
> Regards,
> Andreas



Re: [Qemu-devel] [PULL 00/22] console cleanups & pixman rendering

2012-11-02 Thread Andreas Färber
Am 01.11.2012 20:33, schrieb Anthony Liguori:
> Gerd Hoffmann  writes:
> 
>>   Hi,
>>
>> Sitting on these too long already.  Series has been on the list a while
>> back, only splitted into two parts (separate "console cleanups" series
>> carrying patches 1-8).  Patch 11 was updated according to Paolos
>> suggestion, otherwise the patches are unmodified.
>>
>> please pull,
>>   Gerd
> 
> Pulled. Thanks.

Getting this on SLES 11 SP2 s390x (pixman 0.16.0):

cc1: warnings being treated as errors
In file included from /home/andreas/qemu-s390/qemu-pixman.h:4,
 from /home/andreas/qemu-s390/console.h:5,
 from /home/andreas/qemu-s390/qemu-timer.c:28:
/usr/include/pixman-1/pixman.h:225: error: redundant redeclaration of
‘pixman_transform_from_pixman_f_transform’
/usr/include/pixman-1/pixman.h:221: error: previous declaration of
‘pixman_transform_from_pixman_f_transform’ was here
make: *** [qemu-timer.o] Fehler 1
make: *** Warte auf noch nicht beendete Prozesse...

Any idea how to resolve?

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH 27/28] target-i386: kvm_cpu_fill_host: use GET_SUPPORTED_CPUID

2012-11-02 Thread Eduardo Habkost
On Fri, Nov 02, 2012 at 04:34:00PM +0100, Andreas Färber wrote:
> Am 31.10.2012 10:40, schrieb Marcelo Tosatti:
> > From: Eduardo Habkost 
> > 
> > Change the kvm_cpu_fill_host() function to use
> > kvm_arch_get_supported_cpuid() instead of running the CPUID instruction
> > directly, when checking for supported CPUID features.
> > 
> > This should solve two problems at the same time:
> > 
> >  * "-cpu host" was not enabling features that don't need support on
> >the host CPU (e.g. x2apic);
> >  * "check" and "enforce" options were not detecting problems when the
> >host CPU did support a feature, but the KVM kernel code didn't
> >support it.
> > 
> > Signed-off-by: Eduardo Habkost 
> > Signed-off-by: Marcelo Tosatti 
> > ---
> >  target-i386/cpu.c |   25 +++--
> >  1 files changed, 15 insertions(+), 10 deletions(-)
> > 
> > diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> > index 390ed47..4c84e9f 100644
> > --- a/target-i386/cpu.c
> > +++ b/target-i386/cpu.c
> > @@ -773,13 +773,13 @@ static int cpu_x86_fill_model_id(char *str)
> >   */
> >  static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
> >  {
> > +KVMState *s = kvm_state;
> 
> This broke the linux-user build:
> 
> target-i386/cpu.o: In function `kvm_cpu_fill_host':
> /home/andreas/QEMU/qemu-rcar/target-i386/cpu.c:783: undefined reference
> to `kvm_state'
> collect2: error: ld returned 1 exit status
> make[1]: *** [qemu-i386] Fehler 1
> make: *** [subdir-i386-linux-user] Fehler 2
> 
> Any idea how to fix?

This function should never be called without CONFIG_KVM, so we can
#ifdef out the whole function body. I will send a patch shortly.


> 
> Andreas
> 
> >  uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
> >  
> >  assert(kvm_enabled());
> >  
> >  x86_cpu_def->name = "host";
> >  host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx);
> > -x86_cpu_def->level = eax;
> >  x86_cpu_def->vendor1 = ebx;
> >  x86_cpu_def->vendor2 = edx;
> >  x86_cpu_def->vendor3 = ecx;
> > @@ -788,21 +788,24 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
> >  x86_cpu_def->family = ((eax >> 8) & 0x0F) + ((eax >> 20) & 0xFF);
> >  x86_cpu_def->model = ((eax >> 4) & 0x0F) | ((eax & 0xF) >> 12);
> >  x86_cpu_def->stepping = eax & 0x0F;
> > -x86_cpu_def->ext_features = ecx;
> > -x86_cpu_def->features = edx;
> > +
> > +x86_cpu_def->level = kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);
> > +x86_cpu_def->features = kvm_arch_get_supported_cpuid(s, 0x1, 0, R_EDX);
> > +x86_cpu_def->ext_features = kvm_arch_get_supported_cpuid(s, 0x1, 0, 
> > R_ECX);
> >  
> >  if (x86_cpu_def->level >= 7) {
> > -x86_cpu_def->cpuid_7_0_ebx_features = 
> > kvm_arch_get_supported_cpuid(kvm_state, 0x7, 0, R_EBX);
> > +x86_cpu_def->cpuid_7_0_ebx_features =
> > +kvm_arch_get_supported_cpuid(s, 0x7, 0, R_EBX);
> >  } else {
> >  x86_cpu_def->cpuid_7_0_ebx_features = 0;
> >  }
> >  
> > -host_cpuid(0x8000, 0, &eax, &ebx, &ecx, &edx);
> > -x86_cpu_def->xlevel = eax;
> > +x86_cpu_def->xlevel = kvm_arch_get_supported_cpuid(s, 0x8000, 0, 
> > R_EAX);
> > +x86_cpu_def->ext2_features =
> > +kvm_arch_get_supported_cpuid(s, 0x8001, 0, R_EDX);
> > +x86_cpu_def->ext3_features =
> > +kvm_arch_get_supported_cpuid(s, 0x8001, 0, R_ECX);
> >  
> > -host_cpuid(0x8001, 0, &eax, &ebx, &ecx, &edx);
> > -x86_cpu_def->ext2_features = edx;
> > -x86_cpu_def->ext3_features = ecx;
> >  cpu_x86_fill_model_id(x86_cpu_def->model_id);
> >  x86_cpu_def->vendor_override = 0;
> >  
> > @@ -811,11 +814,13 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
> >  x86_cpu_def->vendor2 == CPUID_VENDOR_VIA_2 &&
> >  x86_cpu_def->vendor3 == CPUID_VENDOR_VIA_3) {
> >  host_cpuid(0xC000, 0, &eax, &ebx, &ecx, &edx);
> > +eax = kvm_arch_get_supported_cpuid(s, 0xC000, 0, R_EAX);
> >  if (eax >= 0xC001) {
> >  /* Support VIA max extended level */
> >  x86_cpu_def->xlevel2 = eax;
> >  host_cpuid(0xC001, 0, &eax, &ebx, &ecx, &edx);
> > -x86_cpu_def->ext4_features = edx;
> > +x86_cpu_def->ext4_features =
> > +kvm_arch_get_supported_cpuid(s, 0xC001, 0, R_EDX);
> >  }
> >  }
> >  
> > 
> 
> 
> -- 
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

-- 
Eduardo



[Qemu-devel] [PATCH] block: vpc initialize the uuid footer field

2012-11-02 Thread Charles Arnold
block/vpc: Initialize the uuid field in the footer with a generated uuid.

Signed-off-by: Charles Arnold 

diff --git a/block/vpc.c b/block/vpc.c
index b6bf52f..f14c6ae 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -26,6 +26,9 @@
 #include "block_int.h"
 #include "module.h"
 #include "migration.h"
+#if defined(CONFIG_UUID)
+#include 
+#endif
 
 /**/
 
@@ -739,7 +742,9 @@ static int vpc_create(const char *filename, 
QEMUOptionParameter *options)
 
 footer->type = be32_to_cpu(disk_type);
 
-/* TODO uuid is missing */
+#if defined(CONFIG_UUID)
+uuid_generate(footer->uuid);
+#endif
 
 footer->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE));
 




Re: [Qemu-devel] [PATCH 27/28] target-i386: kvm_cpu_fill_host: use GET_SUPPORTED_CPUID

2012-11-02 Thread Andreas Färber
Am 02.11.2012 16:34, schrieb Andreas Färber:
> Am 31.10.2012 10:40, schrieb Marcelo Tosatti:
>> From: Eduardo Habkost 
>>
>> Change the kvm_cpu_fill_host() function to use
>> kvm_arch_get_supported_cpuid() instead of running the CPUID instruction
>> directly, when checking for supported CPUID features.
>>
>> This should solve two problems at the same time:
>>
>>  * "-cpu host" was not enabling features that don't need support on
>>the host CPU (e.g. x2apic);
>>  * "check" and "enforce" options were not detecting problems when the
>>host CPU did support a feature, but the KVM kernel code didn't
>>support it.
>>
>> Signed-off-by: Eduardo Habkost 
>> Signed-off-by: Marcelo Tosatti 
>> ---
>>  target-i386/cpu.c |   25 +++--
>>  1 files changed, 15 insertions(+), 10 deletions(-)
>>
>> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
>> index 390ed47..4c84e9f 100644
>> --- a/target-i386/cpu.c
>> +++ b/target-i386/cpu.c
>> @@ -773,13 +773,13 @@ static int cpu_x86_fill_model_id(char *str)
>>   */
>>  static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
>>  {
>> +KVMState *s = kvm_state;
> 
> This broke the linux-user build:
> 
> target-i386/cpu.o: In function `kvm_cpu_fill_host':
> /home/andreas/QEMU/qemu-rcar/target-i386/cpu.c:783: undefined reference
> to `kvm_state'
> collect2: error: ld returned 1 exit status
> make[1]: *** [qemu-i386] Fehler 1
> make: *** [subdir-i386-linux-user] Fehler 2

As a quickfix this would work, but strikes me as ugly:

Signed-off-by: Andreas Färber 

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index c46286a..8663623 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -780,7 +780,11 @@ static int cpu_x86_fill_model_id(char *str)
  */
 static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
 {
+#ifdef CONFIG_KVM
 KVMState *s = kvm_state;
+#else
+KVMState *s = NULL;
+#endif
 uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;

 assert(kvm_enabled());

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH] ui/cocoa.m: Update to new DisplayChangeListener member names

2012-11-02 Thread Andreas Färber
Hi,

Am 02.11.2012 16:41, schrieb Gerd Hoffmann:
>> (I have a philosophical preference for compile fixes being applied
>> directly and quickly to master but my opinion on that matter is
>> not particularly significant :-))
> 
> /me too.  Build fixes should go in on the fast track.  First because a
> broken build is annonying.  Second because buildbots are less useful if
> builds are broken for longer periods.

Fine with me, less work. We should cc a maintainer then. ;)

> One of the reasons I didn't notice the xenfb breakage was because the
> fedora build is broken for other reasons, so the buildbot doesn't came
> to the point where it tries to build xenfb.c and figures it doesn't.
> 
> Should we maybe agree on a special buildfix patch subject tag, so
> maintainers can easily filter and prioritize them?

I used [PATCH buildfix] or so in the past.

Regards,
Andreas



Re: [Qemu-devel] [PATCH] xenfb: fix build breakage caused by console cleanup series

2012-11-02 Thread Andreas Färber
Am 02.11.2012 08:44, schrieb Gerd Hoffmann:
> Console cleanup series renamed dpy_resize and dpy_update all over the
> tree, but hw/xenfb.c was forgotten.  Update it too so it builds again.
> 
> Reported-by: Jan Kiszka 
> Signed-off-by: Gerd Hoffmann 

Acked-by: Andreas Färber 

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH] ui/cocoa.m: Update to new DisplayChangeListener member names

2012-11-02 Thread Gerd Hoffmann
  Hi,

> (I have a philosophical preference for compile fixes being applied
> directly and quickly to master but my opinion on that matter is
> not particularly significant :-))

/me too.  Build fixes should go in on the fast track.  First because a
broken build is annonying.  Second because buildbots are less useful if
builds are broken for longer periods.

One of the reasons I didn't notice the xenfb breakage was because the
fedora build is broken for other reasons, so the buildbot doesn't came
to the point where it tries to build xenfb.c and figures it doesn't.

Should we maybe agree on a special buildfix patch subject tag, so
maintainers can easily filter and prioritize them?

cheers,
  Gerd



Re: [Qemu-devel] live migration which includes previos snapshot

2012-11-02 Thread Eric Blake
On 11/02/2012 09:18 AM, Kuniyasu Suzaki wrote:
>> 1. Make the original image read-only accessible over NFS.
>> 2. Modify QEMU to create two external snapshot files when the VM is
>> paused for migration (during your fork operation):
>>
>> /host-a/original.qcow2
>> /host-a/new.qcow2 (backing file: /host-a/original.qcow2)
>> /host-b/new.qcow2 (backing file: /host-b/original.qcow2)
>>
>> 3. After fork the two VMs will write into their respective new.qcow2
>> files.  original.qcow2 is never modified anymore.
> 
> Does it means nested qcow2?
> Does it allow to use a snapshot image in original.qcow2?
> # I want to share a snapshot image taken by "savevm" on two QEMUs.

This is not yet possible, someone has to step up and write patches to
make it possible.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] live migration which includes previos snapshot

2012-11-02 Thread Eric Blake
On 11/02/2012 09:00 AM, Kuniyasu Suzaki wrote:
>> You are not the first to request this - libvirt would also like the
>> ability to have read-only access into the contents of an internal
>> snapshot while the rest of qemu continues to write into the image.
> 
> Do you mean that libvirt can change the access mode of internal
> harddisk from read-write to read-only?

No.  I meant that reading an internal snapshot (a read-only operation)
while still using the rest of the qcow2 file read-write for live
operation would be a nice feature.  The very nature of the qcow2 file
format means that you cannot have two writers at the same time; the best
you can do is expose the snapshots as a read-only backing file of yet
another qcow2 file if you want a second writer based on the state of the
snapshot without interfering with the first writer.

> Please tell me how to change the mode by libvirt.

Libvirt can't support reading of internal snapshots until qemu supports
it.  In other words, it's a feature no one has written yet, but which
several people want.

> 
> Does the qemu which has read-only access only, use another COW file?
> Nested COWs sound interested, but the inter COW must be read-only, I think.

Correct - any reading of internal snapshots must be read-only - you are
required to use external backing files before you can have multiple
writers sharing a common backing file.

> 
>>> 2. Use Paolo's runtime NBD server to export the snapshot slave when
>>> the VM is forked:
>>
>> An NBD server on top of the read-only state is an additional step that
>> will make access easier.
> 
> Does an NBD work as COW? It looks convenient.

Rather, I'm thinking of making the NBD of the read-only internal
snapshot be the backing file of the new qcow2 layer.  But yes, NBD is
probably the best way for qemu to expose the contents of an internal
snapshot, rather than inventing yet another protocol.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 27/28] target-i386: kvm_cpu_fill_host: use GET_SUPPORTED_CPUID

2012-11-02 Thread Andreas Färber
Am 31.10.2012 10:40, schrieb Marcelo Tosatti:
> From: Eduardo Habkost 
> 
> Change the kvm_cpu_fill_host() function to use
> kvm_arch_get_supported_cpuid() instead of running the CPUID instruction
> directly, when checking for supported CPUID features.
> 
> This should solve two problems at the same time:
> 
>  * "-cpu host" was not enabling features that don't need support on
>the host CPU (e.g. x2apic);
>  * "check" and "enforce" options were not detecting problems when the
>host CPU did support a feature, but the KVM kernel code didn't
>support it.
> 
> Signed-off-by: Eduardo Habkost 
> Signed-off-by: Marcelo Tosatti 
> ---
>  target-i386/cpu.c |   25 +++--
>  1 files changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 390ed47..4c84e9f 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -773,13 +773,13 @@ static int cpu_x86_fill_model_id(char *str)
>   */
>  static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
>  {
> +KVMState *s = kvm_state;

This broke the linux-user build:

target-i386/cpu.o: In function `kvm_cpu_fill_host':
/home/andreas/QEMU/qemu-rcar/target-i386/cpu.c:783: undefined reference
to `kvm_state'
collect2: error: ld returned 1 exit status
make[1]: *** [qemu-i386] Fehler 1
make: *** [subdir-i386-linux-user] Fehler 2

Any idea how to fix?

Andreas

>  uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
>  
>  assert(kvm_enabled());
>  
>  x86_cpu_def->name = "host";
>  host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx);
> -x86_cpu_def->level = eax;
>  x86_cpu_def->vendor1 = ebx;
>  x86_cpu_def->vendor2 = edx;
>  x86_cpu_def->vendor3 = ecx;
> @@ -788,21 +788,24 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
>  x86_cpu_def->family = ((eax >> 8) & 0x0F) + ((eax >> 20) & 0xFF);
>  x86_cpu_def->model = ((eax >> 4) & 0x0F) | ((eax & 0xF) >> 12);
>  x86_cpu_def->stepping = eax & 0x0F;
> -x86_cpu_def->ext_features = ecx;
> -x86_cpu_def->features = edx;
> +
> +x86_cpu_def->level = kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);
> +x86_cpu_def->features = kvm_arch_get_supported_cpuid(s, 0x1, 0, R_EDX);
> +x86_cpu_def->ext_features = kvm_arch_get_supported_cpuid(s, 0x1, 0, 
> R_ECX);
>  
>  if (x86_cpu_def->level >= 7) {
> -x86_cpu_def->cpuid_7_0_ebx_features = 
> kvm_arch_get_supported_cpuid(kvm_state, 0x7, 0, R_EBX);
> +x86_cpu_def->cpuid_7_0_ebx_features =
> +kvm_arch_get_supported_cpuid(s, 0x7, 0, R_EBX);
>  } else {
>  x86_cpu_def->cpuid_7_0_ebx_features = 0;
>  }
>  
> -host_cpuid(0x8000, 0, &eax, &ebx, &ecx, &edx);
> -x86_cpu_def->xlevel = eax;
> +x86_cpu_def->xlevel = kvm_arch_get_supported_cpuid(s, 0x8000, 0, 
> R_EAX);
> +x86_cpu_def->ext2_features =
> +kvm_arch_get_supported_cpuid(s, 0x8001, 0, R_EDX);
> +x86_cpu_def->ext3_features =
> +kvm_arch_get_supported_cpuid(s, 0x8001, 0, R_ECX);
>  
> -host_cpuid(0x8001, 0, &eax, &ebx, &ecx, &edx);
> -x86_cpu_def->ext2_features = edx;
> -x86_cpu_def->ext3_features = ecx;
>  cpu_x86_fill_model_id(x86_cpu_def->model_id);
>  x86_cpu_def->vendor_override = 0;
>  
> @@ -811,11 +814,13 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
>  x86_cpu_def->vendor2 == CPUID_VENDOR_VIA_2 &&
>  x86_cpu_def->vendor3 == CPUID_VENDOR_VIA_3) {
>  host_cpuid(0xC000, 0, &eax, &ebx, &ecx, &edx);
> +eax = kvm_arch_get_supported_cpuid(s, 0xC000, 0, R_EAX);
>  if (eax >= 0xC001) {
>  /* Support VIA max extended level */
>  x86_cpu_def->xlevel2 = eax;
>  host_cpuid(0xC001, 0, &eax, &ebx, &ecx, &edx);
> -x86_cpu_def->ext4_features = edx;
> +x86_cpu_def->ext4_features =
> +kvm_arch_get_supported_cpuid(s, 0xC001, 0, R_EDX);
>  }
>  }
>  
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] buildbot failure in qemu on xen41

2012-11-02 Thread Anthony PERARD
On Fri, Nov 2, 2012 at 7:08 AM, Stefan Hajnoczi  wrote:
> Anthony, your buildslave is missing a package:

Thanks.

> ERROR: pixman not present. Your options:
>   (1) Prefered: Install the pixman devel package (any recent
>   distro should have packages as Xorg needs pixman too).

Done.

>   (2) Fetch the pixman submodule, using:
>   git submodule update --init pixman



--
Anthony PERARD



[Qemu-devel] Fwd: buildbot failure in qemu on openbsd-default

2012-11-02 Thread Gerd Hoffmann


 Original Message 
Subject: buildbot failure in qemu on openbsd-default
Date: Thu, 01 Nov 2012 21:12:01 +0100
From: build...@spunk.home.kraxel.org
To: kraxel...@gmail.com

The Buildbot has detected a failed build on builder openbsd-default
while building qemu.
Full details are available at:
 http://www.kraxel.org/bb/builders/openbsd-default/builds/866

Buildbot URL: http://www.kraxel.org/bb/

Buildslave for this Build: openbsd

Build Reason: scheduler
Build Source Stamp: [branch master] 4ba79505f43bd0ace35c3fe42197eb02e7e0478e
Blamelist: Andreas Färber ,Anthony Liguori
,Dmitry Fleytman ,Don Slutz
,Eduardo Habkost ,Gabriel L.
Somlo ,Gerd Hoffmann ,Igor Mammedov
,Jan Kiszka ,Lei Li
,Marcelo Tosatti ,Paolo
Bonzini ,Peter Maydell
,Stefan Hajnoczi 

BUILD FAILED: failed compile

sincerely,
 -The Buildbot


== log tail ==
  GEN   qapi-visit.c
  CCqapi-visit.o
  CCqapi/qapi-visit-core.o
  CCqapi/qapi-dealloc-visitor.o
  CCqapi/qmp-input-visitor.o
  CCqapi/qmp-output-visitor.o
  CCqapi/qmp-registry.o
  CCqapi/qmp-dispatch.o
  CCqapi/string-input-visitor.o
  CCqapi/string-output-visitor.o
  CCqint.o
  CCqstring.o
  CCqdict.o
  CCqlist.o
  CCqfloat.o
  CCqbool.o
  CCqjson.o
  CCjson-lexer.o
  CCjson-streamer.o
  CCjson-parser.o
  CCqerror.o
  CCerror.o
  CCqemu-error.o
  LINK  qemu-ga
/usr/local/lib/libglib-2.0.so.2992.0: warning: vsprintf() is often
misused, please use vsnprintf()
/usr/local/lib/libglib-2.0.so.2992.0: warning: stpcpy() is dangerous GNU
crap; don't use it
/usr/local/lib/libglib-2.0.so.2992.0: warning: strcpy() is almost always
misused, please use strlcpy()
/usr/local/lib/libglib-2.0.so.2992.0: warning: sprintf() is often
misused, please use snprintf()
qemu-thread-posix.o(.text+0x3ea): In function `qemu_sem_timedwait':
: undefined reference to `sem_timedwait'
collect2: ld returned 1 exit status
gmake: *** [qemu-ga] Error 1

== full log ==
http://www.kraxel.org/bb/builders/openbsd-default/builds/866/steps/compile/logs/stdio




Re: [Qemu-devel] [PATCH v3 27/35] postcopy/outgoing: implement forward/backword prefault

2012-11-02 Thread Eric Blake
On 11/01/2012 11:24 PM, Isaku Yamahata wrote:
>>> +++ b/qapi-schema.json
>>> @@ -2095,7 +2095,8 @@
>>>  ##
>>>  { 'command': 'migrate',
>>>'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', '*detach': 'bool' 
>>> ,
>>> -   '*postcopy': 'bool', '*nobg': 'bool'} }
>>> +   '*postcopy': 'bool', '*nobg': 'bool',
>>> +   '*forward': 'int', '*backward': 'int'} }
>>
>> Do we really want to be adding new options to migrate (and if so,
>> where's the documentation), or do we need a new monitor command similar
>> to migrate-set-capabilities or migrate-set-cache-size?
> 
> Okay, migrate-set-capabilities seems usable for boolean and scalable
> for future extension.
> On the other hand, migrate-set-cache-size takes only single integer
> as arguments. So it doesn't seem usable without modification.
> How about this?
> 
> { 'type': 'MigrationParameters',
>   'data': {'parameter': 'name': 'str', 'value': 'int' } }

More like:

{ 'enum': 'MigrationParameterName',
  'data': ['ParameterName'... ] }

{ 'type': 'MigrationParameter',
  'data': {'parameter': 'MigrationParameterName', 'value': 'int' } }

> 
> { 'command': 'migrate-set-parameters',
>'data': { 'parameters' ['MigrationParameters']}}

Yes, this seems more extensible.

> 
> 
> { 'command': 'query-migrate-parameters',
>   'returns': [['MigrationParameters']]}

One layer too many of [], but yes, this also seems reasonable.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 3/3] apic: always update the in-kernel status after loading

2012-11-02 Thread Paolo Bonzini
Il 02/11/2012 16:17, Gerd Hoffmann ha scritto:
> On 11/02/12 16:13, Paolo Bonzini wrote:
>>> >> Hi,
>>> >>
 >>> I think deferring IRQ events to the point when the complete vmstate
 >>> is loaded is the cleaner and more robust approach.
>>> >>
>>> >> Agree.  Just schedule a bh in post_load.
>>> >> See also a229c0535bd336efaec786dd6e352a54e0a8187d
>> > 
>> > No, it cannot a bh.  Right now incoming migration is blocking,
>> > but this will change in 1.3.  There is no guarantee that a
>> > bottom half will run after migration has completed.
> Then we'll need some new way to do this, maybe a new post_load handler
> which is called once _all_ state is loaded.

The simplest is a vm_clock timer that expires at time 0.

Paolo



Re: [Qemu-devel] [PATCH] ui/cocoa.m: Update to new DisplayChangeListener member names

2012-11-02 Thread Peter Maydell
On 2 November 2012 16:04, Andreas Färber  wrote:
> Am 02.11.2012 15:54, schrieb Peter Maydell:
>> Commit a93a4a2 changed the names of some fields in DisplayChangeListener
>> and broke compilation of the cocoa UI. Update to the new names.
>>
>> Signed-off-by: Peter Maydell 
>
> Reviewed-by: Andreas Färber 
>
> Peter, you didn't cc me - through whose queue is this supposed to go?
> I don't have any other Cocoa patches queued for v1.3.

Sorry, I forgot the cc. I don't care whose queue it goes through
(I have no relevant queue myself).
(I have a philosophical preference for compile fixes being applied
directly and quickly to master but my opinion on that matter is
not particularly significant :-))

-- PMM



Re: [Qemu-devel] live migration which includes previos snapshot

2012-11-02 Thread Kuniyasu Suzaki

Hello Stefan,

From: Stefan Hajnoczi 
Subject: Re: [Qemu-devel] live migration which includes previos snapshot
Date: Fri, 2 Nov 2012 11:30:25 +0100

> If you are forking the VM so that there will be two VMs running
> simultaneously, then a single qcow2 file cannot be used.
> 
> Here are two approaches that will work but require you to modify QEMU code:
> 
> I. Perhaps you can make it work with external snapshots:
> 
> 1. Make the original image read-only accessible over NFS.
> 2. Modify QEMU to create two external snapshot files when the VM is
> paused for migration (during your fork operation):
> 
> /host-a/original.qcow2
> /host-a/new.qcow2 (backing file: /host-a/original.qcow2)
> /host-b/new.qcow2 (backing file: /host-b/original.qcow2)
> 
> 3. After fork the two VMs will write into their respective new.qcow2
> files.  original.qcow2 is never modified anymore.

Does it means nested qcow2?
Does it allow to use a snapshot image in original.qcow2?
# I want to share a snapshot image taken by "savevm" on two QEMUs.

--
suzaki




Re: [Qemu-devel] [PATCH 3/3] apic: always update the in-kernel status after loading

2012-11-02 Thread Gerd Hoffmann
On 11/02/12 16:13, Paolo Bonzini wrote:
>> Hi,
>>
>>> I think deferring IRQ events to the point when the complete vmstate
>>> is
>>> loaded is the cleaner and more robust approach.
>>
>> Agree.  Just schedule a bh in post_load.
>> See also a229c0535bd336efaec786dd6e352a54e0a8187d
> 
> No, it cannot a bh.  Right now incoming migration is blocking,
> but this will change in 1.3.  There is no guarantee that a
> bottom half will run after migration has completed.

Then we'll need some new way to do this, maybe a new post_load handler
which is called once _all_ state is loaded.

cheers,
  Gerd




[Qemu-devel] [PATCH] raw-posix: inline paio_ioctl into hdev_aio_ioctl

2012-11-02 Thread Paolo Bonzini
clang now warns about an unused function:
  CCblock/raw-posix.o
block/raw-posix.c:707:26: warning: unused function paio_ioctl
[-Wunused-function]
static BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,
 ^
1 warning generated.

because the only use of paio_ioctl() is inside a #if defined(__linux__)
guard and it is static now.

Reported-by: Peter Maydell 
Signed-off-by: Paolo Bonzini 
---
 block/raw-posix.c | 27 ++-
 1 file modificato, 10 inserzioni(+), 17 rimozioni(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index f2f0404..488e5f5 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -704,22 +704,6 @@ static BlockDriverAIOCB *paio_submit(BlockDriverState *bs, 
int fd,
 return thread_pool_submit_aio(aio_worker, acb, cb, opaque);
 }
 
-static BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,
-unsigned long int req, void *buf,
-BlockDriverCompletionFunc *cb, void *opaque)
-{
-RawPosixAIOData *acb = g_slice_new(RawPosixAIOData);
-
-acb->bs = bs;
-acb->aio_type = QEMU_AIO_IOCTL;
-acb->aio_fildes = fd;
-acb->aio_offset = 0;
-acb->aio_ioctl_buf = buf;
-acb->aio_ioctl_cmd = req;
-
-return thread_pool_submit_aio(aio_worker, acb, cb, opaque);
-}
-
 static BlockDriverAIOCB *raw_aio_submit(BlockDriverState *bs,
 int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
 BlockDriverCompletionFunc *cb, void *opaque, int type)
@@ -1342,10 +1326,19 @@ static BlockDriverAIOCB 
*hdev_aio_ioctl(BlockDriverState *bs,
 BlockDriverCompletionFunc *cb, void *opaque)
 {
 BDRVRawState *s = bs->opaque;
+RawPosixAIOData *acb;
 
 if (fd_open(bs) < 0)
 return NULL;
-return paio_ioctl(bs, s->fd, req, buf, cb, opaque);
+
+acb = g_slice_new(RawPosixAIOData);
+acb->bs = bs;
+acb->aio_type = QEMU_AIO_IOCTL;
+acb->aio_fildes = s->fd;
+acb->aio_offset = 0;
+acb->aio_ioctl_buf = buf;
+acb->aio_ioctl_cmd = req;
+return thread_pool_submit_aio(aio_worker, acb, cb, opaque);
 }
 
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-- 
1.7.12.1




Re: [Qemu-devel] [PATCH 3/3] apic: always update the in-kernel status after loading

2012-11-02 Thread Paolo Bonzini
> Hi,
> 
> > I think deferring IRQ events to the point when the complete vmstate
> > is
> > loaded is the cleaner and more robust approach.
> 
> Agree.  Just schedule a bh in post_load.
> See also a229c0535bd336efaec786dd6e352a54e0a8187d

No, it cannot a bh.  Right now incoming migration is blocking,
but this will change in 1.3.  There is no guarantee that a
bottom half will run after migration has completed.

Paolo




[Qemu-devel] [PATCH v2 4/5] vl: unify calls to init_timer_alarm

2012-11-02 Thread Paolo Bonzini
init_timer_alarm was being called twice.  This is not needed.

Signed-off-by: Paolo Bonzini 
---
 main-loop.c | 5 -
 vl.c| 5 -
 2 file modificati, 4 inserzioni(+), 6 rimozioni(-)

diff --git a/main-loop.c b/main-loop.c
index e43c7c8..234a313 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -123,7 +123,10 @@ int qemu_init_main_loop(void)
 GSource *src;
 
 init_clocks();
-init_timer_alarm();
+if (init_timer_alarm() < 0) {
+fprintf(stderr, "could not initialize alarm timer\n");
+exit(1);
+}
 
 qemu_mutex_lock_iothread();
 ret = qemu_signal_init();
diff --git a/vl.c b/vl.c
index 99681da..e2d5276 100644
--- a/vl.c
+++ b/vl.c
@@ -3616,11 +3616,6 @@ int main(int argc, char **argv, char **envp)
 add_device_config(DEV_VIRTCON, "vc:80Cx24C");
 }
 
-if (init_timer_alarm() < 0) {
-fprintf(stderr, "could not initialize alarm timer\n");
-exit(1);
-}
-
 socket_init();
 
 if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 
1) != 0)
-- 
1.7.12.1





Re: [Qemu-devel] [PATCH v2 0/5] Fixes for thread pool patches.

2012-11-02 Thread Peter Maydell
On 2 November 2012 15:43, Paolo Bonzini  wrote:
> Three fixes: 1) Darwin does not support weak aliases, use weak
> references instead.  2) Darwin, NetBSD and OpenBSD do not have
> sem_timedwait, implement counting semaphores with a mutex and
> cv there.  3) Daemonize was broken, fixes are in patches 3-5.

v2 patches 1 & 2 compile cleanly on macos and the resulting
qemu seems to work (smoke tested only).

thanks
-- PMM



Re: [Qemu-devel] [PATCH 3/3] apic: always update the in-kernel status after loading

2012-11-02 Thread Gerd Hoffmann
  Hi,

> I think deferring IRQ events to the point when the complete vmstate is
> loaded is the cleaner and more robust approach.

Agree.  Just schedule a bh in post_load.
See also a229c0535bd336efaec786dd6e352a54e0a8187d

cheers,
  Gerd



Re: [Qemu-devel] [PATCH] ui/cocoa.m: Update to new DisplayChangeListener member names

2012-11-02 Thread Andreas Färber
Am 02.11.2012 15:54, schrieb Peter Maydell:
> Commit a93a4a2 changed the names of some fields in DisplayChangeListener
> and broke compilation of the cocoa UI. Update to the new names.
> 
> Signed-off-by: Peter Maydell 

Reviewed-by: Andreas Färber 

Peter, you didn't cc me - through whose queue is this supposed to go?
I don't have any other Cocoa patches queued for v1.3.

Thanks,
Andreas




Re: [Qemu-devel] live migration which includes previos snapshot

2012-11-02 Thread Kuniyasu Suzaki

Hello Eric,

From: Eric Blake 
Subject: Re: [Qemu-devel] live migration which includes previos snapshot
Date: Fri, 02 Nov 2012 07:12:21 -0600

> On 11/02/2012 04:30 AM, Stefan Hajnoczi wrote:
> 
> > II. If you want to use internal snapshots in a single qcow2 file, you
> > will need to modify QEMU code more:
> > 1. Implement BlockDriverState snapshot slave support so a qcow2
> > snapshot can be read-only accessed as a BlockDriverState while the
> > master BlockDriverState for the image still writes into the image
> > file.  This is mainly qcow2 refactoring and block.c glue code.
> 
> You are not the first to request this - libvirt would also like the
> ability to have read-only access into the contents of an internal
> snapshot while the rest of qemu continues to write into the image.

Do you mean that libvirt can change the access mode of internal
harddisk from read-write to read-only?
Please tell me how to change the mode by libvirt.

Does the qemu which has read-only access only, use another COW file?
Nested COWs sound interested, but the inter COW must be read-only, I think.

> > 2. Use Paolo's runtime NBD server to export the snapshot slave when
> > the VM is forked:
> 
> An NBD server on top of the read-only state is an additional step that
> will make access easier.

Does an NBD work as COW? It looks convenient.

Thank you.
--
suzaki




Re: [Qemu-devel] [PATCH v2 35/39] raw: merge posix-aio-compat.c into block/raw-posix.c

2012-11-02 Thread Peter Maydell
On 31 October 2012 16:30, Paolo Bonzini  wrote:
> Making the qemu_paiocb specific to raw devices will let us access members
> of the BDRVRawState arbitrarily.
>
> Signed-off-by: Paolo Bonzini 

clang now warns about an unused function:
  CCblock/raw-posix.o
block/raw-posix.c:707:26: warning: unused function 'paio_ioctl'
[-Wunused-function]
static BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,
 ^
1 warning generated.

because the only use of paio_ioctl() is inside a #if defined(__linux__)
guard and it's 'static' now.

-- PMM



Re: [Qemu-devel] [PATCHv2 1/4] Adding new syscalls (bugzilla 855162)

2012-11-02 Thread Corey Bryant



On 11/02/2012 10:38 AM, Paul Moore wrote:

On Friday, November 02, 2012 10:10:02 AM Paul Moore wrote:

On Friday, November 02, 2012 09:48:55 AM Corey Bryant wrote:

On 11/01/2012 05:43 PM, Paul Moore wrote:

On Tuesday, October 23, 2012 03:55:29 AM Eduardo Otubo wrote:

According to the bug 855162[0] - there's the need of adding new
syscalls
to the whitelist whenn using Qemu with Libvirt.

[0] - https://bugzilla.redhat.com/show_bug.cgi?id=855162

v2: Adding new syscalls to the list: readlink, rt_sigpending, and

  rt_sigtimedwait

Reported-by: Paul Moore 
Signed-off-by: Eduardo Otubo 
---

   qemu-seccomp.c | 13 -
   1 file changed, 12 insertions(+), 1 deletion(-)


I had an opportunity to test this patchset on a F17 machine using QEMU
1.2
and unfortunately it still fails.  I'm using a relatively basic guest
configuration running F16, the details are documented in the RH BZ that
Eduardo mentioned in the patch description.


Paul, Here's the latest diff for the whitelist.  We're looking to get
the patches out in the next few days after a bit more testing.


Okay, thanks for the updated list ... I'm rebuilding QEMU right now and I'll
report back with the results later today.


Sadly, no luck, it still fails.



Hmm, let me send you the current patch set off-line, which includes 
debug support to write the failing syscall out.  If you don't mind could 
you try it out?


--
Regards,
Corey Bryant




Re: [Qemu-devel] [PATCH 3/3] apic: always update the in-kernel status after loading

2012-11-02 Thread Jan Kiszka
On 2012-11-02 15:53, Paolo Bonzini wrote:
> Il 30/10/2012 19:21, Jan Kiszka ha scritto:
 Aren't we still dependent on the order of processing?  If the APIC is
 restored after the device, won't we get the same problem?
>>>
>>> Strictly speaking yes, but CPUs and APICs are always the first devices
>>> to be saved.
>> Hmm, thinking about this again: Why is the MSI event injected at all
>> during restore, specifically while the device models are in transitional
>> state. Can you explain this?
> 
> Because the (virtio-serial) port was connected on the source and
> disconnected on the destination, or vice versa.
> 
> In my simplified reproducer, I'm really using different command-lines on
> the source and destination, but it is not necessary.  For example, if
> you have a socket backend, the destination will usually be disconnected
> at the time the machine loads.
> 
> One alternative fix is a vm_clock timer that expires immediately.  It
> would fix both MSI and INTx, on the other hand I thought it was an APIC
> bug because the QEMU APIC works nicely.

I think deferring IRQ events to the point when the complete vmstate is
loaded is the cleaner and more robust approach.

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux



Re: [Qemu-devel] [PATCH] ui/cocoa.m: Update to new DisplayChangeListener member names

2012-11-02 Thread Gerd Hoffmann
On 11/02/12 15:54, Peter Maydell wrote:
> Commit a93a4a2 changed the names of some fields in DisplayChangeListener
> and broke compilation of the cocoa UI. Update to the new names.
> 
> Signed-off-by: Peter Maydell 

Acked-by: Gerd Hoffmann 

cheers,
  Gerd



[Qemu-devel] [PATCH v2 5/5] vl: delay thread initialization after daemonization

2012-11-02 Thread Paolo Bonzini
Commit ac4119c (chardev: Use timer instead of bottom-half to postpone
open event, 2012-10-12) moved the alarm timer initialization to an earlier
point but failed to consider that it depends on qemu_init_main_loop.

Later, commit 1c53786 (vl: init main loop earlier, 2012-10-30) fixed
this, but left -daemonize in two different ways.  First, timers need to
be reinitialized after forking.  Second, the global mutex was being held
by the parent, and thus dropped after forking.

The first is now fixed using pthread_atfork.  For the second part,
make sure that the global mutex is not taken before daemonization,
and similarly delay qemu_thread_self.

Signed-off-by: Paolo Bonzini 
---
 main-loop.c | 1 -
 vl.c| 4 +++-
 2 file modificati, 3 inserzioni(+), 2 rimozioni(-)

diff --git a/main-loop.c b/main-loop.c
index 234a313..c87624e 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -128,7 +128,6 @@ int qemu_init_main_loop(void)
 exit(1);
 }
 
-qemu_mutex_lock_iothread();
 ret = qemu_signal_init();
 if (ret) {
 return ret;
diff --git a/vl.c b/vl.c
index e2d5276..0f5b07b 100644
--- a/vl.c
+++ b/vl.c
@@ -3477,7 +3477,6 @@ int main(int argc, char **argv, char **envp)
 }
 loc_set_none();
 
-qemu_init_cpu_loop();
 if (qemu_init_main_loop()) {
 fprintf(stderr, "qemu_init_main_loop failed\n");
 exit(1);
@@ -3677,6 +3676,9 @@ int main(int argc, char **argv, char **envp)
 
 os_set_line_buffering();
 
+qemu_init_cpu_loop();
+qemu_mutex_lock_iothread();
+
 #ifdef CONFIG_SPICE
 /* spice needs the timers to be initialized by this point */
 qemu_spice_init();
-- 
1.7.12.1




[Qemu-devel] [PATCH] ui/cocoa.m: Update to new DisplayChangeListener member names

2012-11-02 Thread Peter Maydell
Commit a93a4a2 changed the names of some fields in DisplayChangeListener
and broke compilation of the cocoa UI. Update to the new names.

Signed-off-by: Peter Maydell 
---
 ui/cocoa.m | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2383646..87d2e44 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1017,8 +1017,8 @@ void cocoa_display_init(DisplayState *ds, int full_screen)
 dcl = g_malloc0(sizeof(DisplayChangeListener));
 
 // register vga output callbacks
-dcl->dpy_update = cocoa_update;
-dcl->dpy_resize = cocoa_resize;
+dcl->dpy_gfx_update = cocoa_update;
+dcl->dpy_gfx_resize = cocoa_resize;
 dcl->dpy_refresh = cocoa_refresh;
 
register_displaychangelistener(ds, dcl);
-- 
1.7.11.4




Re: [Qemu-devel] [PATCH 3/3] apic: always update the in-kernel status after loading

2012-11-02 Thread Paolo Bonzini
Il 30/10/2012 19:21, Jan Kiszka ha scritto:
> > > Aren't we still dependent on the order of processing?  If the APIC is
> > > restored after the device, won't we get the same problem?
> > 
> > Strictly speaking yes, but CPUs and APICs are always the first devices
> > to be saved.
> Hmm, thinking about this again: Why is the MSI event injected at all
> during restore, specifically while the device models are in transitional
> state. Can you explain this?

Because the (virtio-serial) port was connected on the source and
disconnected on the destination, or vice versa.

In my simplified reproducer, I'm really using different command-lines on
the source and destination, but it is not necessary.  For example, if
you have a socket backend, the destination will usually be disconnected
at the time the machine loads.

One alternative fix is a vm_clock timer that expires immediately.  It
would fix both MSI and INTx, on the other hand I thought it was an APIC
bug because the QEMU APIC works nicely.

> Does the same pattern then also apply on INTx injection?

Yes.

Paolo



Re: [Qemu-devel] [PATCH v2 3/3] aio: rename AIOPool to AIOCBInfo

2012-11-02 Thread Paolo Bonzini
Il 31/10/2012 16:34, Stefan Hajnoczi ha scritto:
> Now that AIOPool no longer keeps a freelist, it isn't really a "pool"
> anymore.  Rename it to AIOCBInfo and make it const since it no longer
> needs to be modified.
> 
> Signed-off-by: Stefan Hajnoczi 
> ---
>  block.c   | 22 +++---
>  block/blkdebug.c  |  4 ++--
>  block/blkverify.c |  4 ++--
>  block/curl.c  |  4 ++--
>  block/gluster.c   |  6 +++---
>  block/iscsi.c | 12 ++--
>  block/linux-aio.c |  4 ++--
>  block/qed.c   |  4 ++--
>  block/rbd.c   |  4 ++--
>  block/sheepdog.c  |  4 ++--
>  block/win32-aio.c |  4 ++--
>  dma-helpers.c |  4 ++--
>  hw/ide/core.c |  4 ++--
>  qemu-aio.h|  8 
>  thread-pool.c |  4 ++--
>  15 files changed, 46 insertions(+), 46 deletions(-)
> 
> diff --git a/block.c b/block.c
> index ea0f7d8..854ebd6 100644
> --- a/block.c
> +++ b/block.c
> @@ -3521,7 +3521,7 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, 
> BlockRequest *reqs, int num_reqs)
>  
>  void bdrv_aio_cancel(BlockDriverAIOCB *acb)
>  {
> -acb->pool->cancel(acb);
> +acb->aiocb_info->cancel(acb);
>  }
>  
>  /* block I/O throttling */
> @@ -3711,7 +3711,7 @@ static void bdrv_aio_cancel_em(BlockDriverAIOCB 
> *blockacb)
>  qemu_aio_release(acb);
>  }
>  
> -static AIOPool bdrv_em_aio_pool = {
> +static const AIOCBInfo bdrv_em_aiocb_info = {
>  .aiocb_size = sizeof(BlockDriverAIOCBSync),
>  .cancel = bdrv_aio_cancel_em,
>  };
> @@ -3740,7 +3740,7 @@ static BlockDriverAIOCB 
> *bdrv_aio_rw_vector(BlockDriverState *bs,
>  {
>  BlockDriverAIOCBSync *acb;
>  
> -acb = qemu_aio_get(&bdrv_em_aio_pool, bs, cb, opaque);
> +acb = qemu_aio_get(&bdrv_em_aiocb_info, bs, cb, opaque);
>  acb->is_write = is_write;
>  acb->qiov = qiov;
>  acb->bounce = qemu_blockalign(bs, qiov->size);
> @@ -3785,7 +3785,7 @@ static void bdrv_aio_co_cancel_em(BlockDriverAIOCB 
> *blockacb)
>  qemu_aio_flush();
>  }
>  
> -static AIOPool bdrv_em_co_aio_pool = {
> +static const AIOCBInfo bdrv_em_co_aiocb_info = {
>  .aiocb_size = sizeof(BlockDriverAIOCBCoroutine),
>  .cancel = bdrv_aio_co_cancel_em,
>  };
> @@ -3828,7 +3828,7 @@ static BlockDriverAIOCB 
> *bdrv_co_aio_rw_vector(BlockDriverState *bs,
>  Coroutine *co;
>  BlockDriverAIOCBCoroutine *acb;
>  
> -acb = qemu_aio_get(&bdrv_em_co_aio_pool, bs, cb, opaque);
> +acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque);
>  acb->req.sector = sector_num;
>  acb->req.nb_sectors = nb_sectors;
>  acb->req.qiov = qiov;
> @@ -3858,7 +3858,7 @@ BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs,
>  Coroutine *co;
>  BlockDriverAIOCBCoroutine *acb;
>  
> -acb = qemu_aio_get(&bdrv_em_co_aio_pool, bs, cb, opaque);
> +acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque);
>  co = qemu_coroutine_create(bdrv_aio_flush_co_entry);
>  qemu_coroutine_enter(co, acb);
>  
> @@ -3884,7 +3884,7 @@ BlockDriverAIOCB *bdrv_aio_discard(BlockDriverState *bs,
>  
>  trace_bdrv_aio_discard(bs, sector_num, nb_sectors, opaque);
>  
> -acb = qemu_aio_get(&bdrv_em_co_aio_pool, bs, cb, opaque);
> +acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque);
>  acb->req.sector = sector_num;
>  acb->req.nb_sectors = nb_sectors;
>  co = qemu_coroutine_create(bdrv_aio_discard_co_entry);
> @@ -3904,13 +3904,13 @@ void bdrv_init_with_whitelist(void)
>  bdrv_init();
>  }
>  
> -void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs,
> +void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs,
> BlockDriverCompletionFunc *cb, void *opaque)
>  {
>  BlockDriverAIOCB *acb;
>  
> -acb = g_slice_alloc(pool->aiocb_size);
> -acb->pool = pool;
> +acb = g_slice_alloc(aiocb_info->aiocb_size);
> +acb->aiocb_info = aiocb_info;
>  acb->bs = bs;
>  acb->cb = cb;
>  acb->opaque = opaque;
> @@ -3920,7 +3920,7 @@ void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs,
>  void qemu_aio_release(void *p)
>  {
>  BlockDriverAIOCB *acb = p;
> -g_slice_free1(acb->pool->aiocb_size, acb);
> +g_slice_free1(acb->aiocb_info->aiocb_size, acb);
>  }
>  
>  /**/
> diff --git a/block/blkdebug.c b/block/blkdebug.c
> index 1206d52..d61ece8 100644
> --- a/block/blkdebug.c
> +++ b/block/blkdebug.c
> @@ -41,7 +41,7 @@ typedef struct BlkdebugAIOCB {
>  
>  static void blkdebug_aio_cancel(BlockDriverAIOCB *blockacb);
>  
> -static AIOPool blkdebug_aio_pool = {
> +static const AIOCBInfo blkdebug_aiocb_info = {
>  .aiocb_size = sizeof(BlkdebugAIOCB),
>  .cancel = blkdebug_aio_cancel,
>  };
> @@ -335,7 +335,7 @@ static BlockDriverAIOCB *inject_error(BlockDriverState 
> *bs,
>  return NULL;
>  }
>  
> -acb = qemu_aio_get(&blkdebug_aio_pool, bs, cb, opaque);
> +acb = qemu_aio_get(&blkdebug_aiocb_info, bs, 

Re: [Qemu-devel] [PATCHv2 1/4] Adding new syscalls (bugzilla 855162)

2012-11-02 Thread Corey Bryant



On 11/02/2012 10:46 AM, Paul Moore wrote:

On Friday, November 02, 2012 10:43:41 AM Corey Bryant wrote:

On 11/02/2012 10:38 AM, Paul Moore wrote:

On Friday, November 02, 2012 10:10:02 AM Paul Moore wrote:

On Friday, November 02, 2012 09:48:55 AM Corey Bryant wrote:

On 11/01/2012 05:43 PM, Paul Moore wrote:

On Tuesday, October 23, 2012 03:55:29 AM Eduardo Otubo wrote:

According to the bug 855162[0] - there's the need of adding new
syscalls
to the whitelist whenn using Qemu with Libvirt.

[0] - https://bugzilla.redhat.com/show_bug.cgi?id=855162

v2: Adding new syscalls to the list: readlink, rt_sigpending, and

   rt_sigtimedwait

Reported-by: Paul Moore 
Signed-off-by: Eduardo Otubo 
---

qemu-seccomp.c | 13 -
1 file changed, 12 insertions(+), 1 deletion(-)


I had an opportunity to test this patchset on a F17 machine using QEMU
1.2
and unfortunately it still fails.  I'm using a relatively basic guest
configuration running F16, the details are documented in the RH BZ that
Eduardo mentioned in the patch description.


Paul, Here's the latest diff for the whitelist.  We're looking to get
the patches out in the next few days after a bit more testing.


Okay, thanks for the updated list ... I'm rebuilding QEMU right now and
I'll report back with the results later today.


Sadly, no luck, it still fails.


Hmm, let me send you the current patch set off-line, which includes
debug support to write the failing syscall out.  If you don't mind could
you try it out?


Sure, no problem.

On a related note, I think it would be a *really* good idea to also submit the
debug code upstream, just in a disabled state by default.  You could either
bracket it with #ifdefs or get fancy and allow it at runtime with '-sandbox
debug' or something similar.



I agree.  That's the plan with the v3 patch series.  We'll get them out 
in the next few days.


--
Regards,
Corey Bryant




Re: [Qemu-devel] [PATCH v2 2/3] aio: use g_slice_alloc() for AIOCB pooling

2012-11-02 Thread Paolo Bonzini
Il 31/10/2012 16:34, Stefan Hajnoczi ha scritto:
> AIO control blocks are frequently acquired and released because each aio
> request involves at least one AIOCB.  Therefore, we pool them to avoid
> heap allocation overhead.
> 
> The problem with the freelist approach in AIOPool is thread-safety.  If
> we want BlockDriverStates to associate with AioContexts that execute in
> multiple threads, then a global freelist becomes a problem.
> 
> This patch drops the freelist and instead uses g_slice_alloc() which is
> tuned for per-thread fixed-size object pools.  qemu_aio_get() and
> qemu_aio_release() are now thread-safe.
> 
> Note that the change from g_malloc0() to g_slice_alloc() should be safe
> since the freelist reuse case doesn't zero the AIOCB either.
> 
> Signed-off-by: Stefan Hajnoczi 
> ---
>  block.c| 15 ---
>  qemu-aio.h |  2 --
>  2 files changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/block.c b/block.c
> index da1fdca..ea0f7d8 100644
> --- a/block.c
> +++ b/block.c
> @@ -3909,13 +3909,8 @@ void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs,
>  {
>  BlockDriverAIOCB *acb;
>  
> -if (pool->free_aiocb) {
> -acb = pool->free_aiocb;
> -pool->free_aiocb = acb->next;
> -} else {
> -acb = g_malloc0(pool->aiocb_size);
> -acb->pool = pool;
> -}
> +acb = g_slice_alloc(pool->aiocb_size);
> +acb->pool = pool;
>  acb->bs = bs;
>  acb->cb = cb;
>  acb->opaque = opaque;
> @@ -3924,10 +3919,8 @@ void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs,
>  
>  void qemu_aio_release(void *p)
>  {
> -BlockDriverAIOCB *acb = (BlockDriverAIOCB *)p;
> -AIOPool *pool = acb->pool;
> -acb->next = pool->free_aiocb;
> -pool->free_aiocb = acb;
> +BlockDriverAIOCB *acb = p;
> +g_slice_free1(acb->pool->aiocb_size, acb);
>  }
>  
>  /**/
> diff --git a/qemu-aio.h b/qemu-aio.h
> index 111b0b3..b29c509 100644
> --- a/qemu-aio.h
> +++ b/qemu-aio.h
> @@ -24,7 +24,6 @@ typedef void BlockDriverCompletionFunc(void *opaque, int 
> ret);
>  typedef struct AIOPool {
>  void (*cancel)(BlockDriverAIOCB *acb);
>  size_t aiocb_size;
> -BlockDriverAIOCB *free_aiocb;
>  } AIOPool;
>  
>  struct BlockDriverAIOCB {
> @@ -32,7 +31,6 @@ struct BlockDriverAIOCB {
>  BlockDriverState *bs;
>  BlockDriverCompletionFunc *cb;
>  void *opaque;
> -BlockDriverAIOCB *next;
>  };
>  
>  void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs,
> 

Reviewed-by: Paolo Bonzini 




Re: [Qemu-devel] [PATCH v2 1/3] aio: switch aiocb_size type int -> size_t

2012-11-02 Thread Paolo Bonzini
Il 31/10/2012 16:34, Stefan Hajnoczi ha scritto:
> Using appropriate types for variables is a good thing :).  All users
> simply do sizeof(MyType) and the value is passed to a memory allocator,
> it should be size_t.
> 
> Signed-off-by: Stefan Hajnoczi 
> ---
>  qemu-aio.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qemu-aio.h b/qemu-aio.h
> index 1b7eb6e..111b0b3 100644
> --- a/qemu-aio.h
> +++ b/qemu-aio.h
> @@ -23,7 +23,7 @@ typedef void BlockDriverCompletionFunc(void *opaque, int 
> ret);
>  
>  typedef struct AIOPool {
>  void (*cancel)(BlockDriverAIOCB *acb);
> -int aiocb_size;
> +size_t aiocb_size;
>  BlockDriverAIOCB *free_aiocb;
>  } AIOPool;
>  
> 

Reviewed-by: Paolo Bonzini 



Re: [Qemu-devel] [PATCHv2 1/4] Adding new syscalls (bugzilla 855162)

2012-11-02 Thread Paul Moore
On Friday, November 02, 2012 10:43:41 AM Corey Bryant wrote:
> On 11/02/2012 10:38 AM, Paul Moore wrote:
> > On Friday, November 02, 2012 10:10:02 AM Paul Moore wrote:
> >> On Friday, November 02, 2012 09:48:55 AM Corey Bryant wrote:
> >>> On 11/01/2012 05:43 PM, Paul Moore wrote:
>  On Tuesday, October 23, 2012 03:55:29 AM Eduardo Otubo wrote:
> > According to the bug 855162[0] - there's the need of adding new
> > syscalls
> > to the whitelist whenn using Qemu with Libvirt.
> > 
> > [0] - https://bugzilla.redhat.com/show_bug.cgi?id=855162
> > 
> > v2: Adding new syscalls to the list: readlink, rt_sigpending, and
> > 
> >   rt_sigtimedwait
> > 
> > Reported-by: Paul Moore 
> > Signed-off-by: Eduardo Otubo 
> > ---
> > 
> >qemu-seccomp.c | 13 -
> >1 file changed, 12 insertions(+), 1 deletion(-)
>  
>  I had an opportunity to test this patchset on a F17 machine using QEMU
>  1.2
>  and unfortunately it still fails.  I'm using a relatively basic guest
>  configuration running F16, the details are documented in the RH BZ that
>  Eduardo mentioned in the patch description.
> >>> 
> >>> Paul, Here's the latest diff for the whitelist.  We're looking to get
> >>> the patches out in the next few days after a bit more testing.
> >> 
> >> Okay, thanks for the updated list ... I'm rebuilding QEMU right now and
> >> I'll report back with the results later today.
> > 
> > Sadly, no luck, it still fails.
> 
> Hmm, let me send you the current patch set off-line, which includes
> debug support to write the failing syscall out.  If you don't mind could
> you try it out?

Sure, no problem.

On a related note, I think it would be a *really* good idea to also submit the 
debug code upstream, just in a disabled state by default.  You could either 
bracket it with #ifdefs or get fancy and allow it at runtime with '-sandbox 
debug' or something similar.

-- 
paul moore
security and virtualization @ redhat




Re: [Qemu-devel] [PATCH] virtio: limit avail bytes lookahead

2012-11-02 Thread Michael S. Tsirkin
On Fri, Nov 02, 2012 at 11:18:18AM +0100, Stefan Hajnoczi wrote:
> On Thu, Nov 1, 2012 at 5:07 PM, Michael S. Tsirkin  wrote:
> > Commit 0d8d7690850eb0cf2b2b60933cf47669a6b6f18f introduced
> > a regression in virtio-net performance because it looks
> > into the ring aggressively while we really only care
> > about a single packet worth of buffers.
> > To fix, add parameters limiting lookahead, and
> > use in virtqueue_avail_bytes.
> >
> > Signed-off-by: Michael S. Tsirkin 
> > Reported-by: Edivaldo de Araujo Pereira 
> 
> Nice, much simpler than the ideas I had.
> 
> Reviewed-by: Stefan Hajnoczi 

Anthony could you apply this out of band please so this stops
biting people?

Thanks,
MST



Re: [Qemu-devel] [PATCH 05/22] console: untangle gfx & txt updates

2012-11-02 Thread Peter Maydell
On 2 November 2012 08:20, Jan Kiszka  wrote:
> On 2012-11-01 14:04, Gerd Hoffmann wrote:
>> Stop abusing displaysurface fields for text mode displays.
>> (bpp = 0, width = cols, height = lines).
>>
>> Add flags to displaystate indicating whenever text mode display
>> (curses) or gfx mode displays (sdl, vnc, ...) are present.
>>
>> Add separate displaychangelistener callbacks for text / gfx mode
>> resize & updates.
>>
>> This allows to enable gfx and txt diplays at the same time and also
>> paves the way for more cleanups in the future.
>
> Breaks building xenfb.c.

Also breaks building the Cocoa frontend on MacOS:

  OBJC  ui/cocoa.o
ui/cocoa.m:771:10: warning:
  
'beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:'
is
  deprecated [-Wdeprecated-declarations]
[op beginSheetForDirectory:nil file:nil types:[NSArray ...
 ^
ui/cocoa.m:810:32: warning: 'filename' is deprecated [-Wdeprecated-declarations]
char *img = (char*)[ [ sheet filename ]
cStringUsingEncoding:NSASCIIStringEncoding];
   ^
ui/cocoa.m:1020:10: error: no member named 'dpy_update' in 'struct
DisplayChangeListener'
dcl->dpy_update = cocoa_update;
~~~  ^
ui/cocoa.m:1021:10: error: no member named 'dpy_resize' in 'struct
DisplayChangeListener'
dcl->dpy_resize = cocoa_resize;
~~~  ^
2 warnings and 2 errors generated.
make: *** [ui/cocoa.o] Error 1

'git grep dpy_update' suggests that xenfb and cocoa are the only two
breakages though.


-- PMM



[Qemu-devel] [PATCH v2 3/5] qemu-timer: reinitialize timers after fork

2012-11-02 Thread Paolo Bonzini
Timers are not inherited by the child of a fork(2), so just use
pthread_atfork to reinstate them after daemonize.

Signed-off-by: Paolo Bonzini 
---
 qemu-timer.c | 14 ++
 1 file modificato, 14 inserzioni(+)

diff --git a/qemu-timer.c b/qemu-timer.c
index f3426c9..7b2217a 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -742,6 +742,17 @@ static void quit_timers(void)
 t->stop(t);
 }
 
+static void reinit_timers(void)
+{
+struct qemu_alarm_timer *t = alarm_timer;
+t->stop(t);
+if (t->start(t)) {
+fprintf(stderr, "Internal timer error: aborting\n");
+exit(1);
+}
+qemu_rearm_alarm_timer(t);
+}
+
 int init_timer_alarm(void)
 {
 struct qemu_alarm_timer *t = NULL;
@@ -765,6 +776,9 @@ int init_timer_alarm(void)
 }
 
 atexit(quit_timers);
+#ifdef CONFIG_POSIX
+pthread_atfork(NULL, NULL, reinit_timers);
+#endif
 alarm_timer = t;
 return 0;
 
-- 
1.7.12.1





[Qemu-devel] [PATCH v2 2/5] semaphore: implement fallback counting semaphores with mutex+condvar

2012-11-02 Thread Paolo Bonzini
OpenBSD and Darwin do not have sem_timedwait.  Implement a fallback
for them.

Signed-off-by: Paolo Bonzini 
---
v1->v2: extract compute_abs_deadline and use it

 qemu-thread-posix.c | 92 +++--
 qemu-thread-posix.h |  6 
 2 file modificati, 88 inserzioni(+), 10 rimozioni(-)

diff --git a/qemu-thread-posix.c b/qemu-thread-posix.c
index 6a3d3a1..4ef9c7b 100644
--- a/qemu-thread-posix.c
+++ b/qemu-thread-posix.c
@@ -122,36 +122,106 @@ void qemu_sem_init(QemuSemaphore *sem, int init)
 {
 int rc;
 
+#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+rc = pthread_mutex_init(&sem->lock, NULL);
+if (rc != 0) {
+error_exit(rc, __func__);
+}
+rc = pthread_cond_init(&sem->cond, NULL);
+if (rc != 0) {
+error_exit(rc, __func__);
+}
+if (init < 0) {
+error_exit(EINVAL, __func__);
+}
+sem->count = init;
+#else
 rc = sem_init(&sem->sem, 0, init);
 if (rc < 0) {
 error_exit(errno, __func__);
 }
+#endif
 }
 
 void qemu_sem_destroy(QemuSemaphore *sem)
 {
 int rc;
 
+#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+rc = pthread_cond_destroy(&sem->cond);
+if (rc < 0) {
+error_exit(rc, __func__);
+}
+rc = pthread_mutex_destroy(&sem->lock);
+if (rc < 0) {
+error_exit(rc, __func__);
+}
+#else
 rc = sem_destroy(&sem->sem);
 if (rc < 0) {
 error_exit(errno, __func__);
 }
+#endif
 }
 
 void qemu_sem_post(QemuSemaphore *sem)
 {
 int rc;
 
+#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+pthread_mutex_lock(&sem->lock);
+if (sem->count == INT_MAX) {
+rc = EINVAL;
+} else if (sem->count++ < 0) {
+rc = pthread_cond_signal(&sem->cond);
+} else {
+rc = 0;
+}
+pthread_mutex_unlock(&sem->lock);
+if (rc != 0) {
+error_exit(rc, __func__);
+}
+#else
 rc = sem_post(&sem->sem);
 if (rc < 0) {
 error_exit(errno, __func__);
 }
+#endif
+}
+
+static void compute_abs_deadline(struct timespec *ts, int ms)
+{
+struct timeval tv;
+gettimeofday(&tv, NULL);
+ts->tv_nsec = tv.tv_usec * 1000 + (ms % 1000) * 100;
+ts->tv_sec = tv.tv_sec + ms / 1000;
+if (ts->tv_nsec >= 10) {
+ts->tv_sec++;
+ts->tv_nsec -= 10;
+}
 }
 
 int qemu_sem_timedwait(QemuSemaphore *sem, int ms)
 {
 int rc;
-
+struct timespec ts;
+
+#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+compute_abs_deadline(&ts, ms);
+pthread_mutex_lock(&sem->lock);
+--sem->count;
+while (sem->count < 0) {
+rc = pthread_cond_timedwait(&sem->cond, &sem->lock, &ts);
+if (rc == ETIMEDOUT) {
+break;
+}
+if (rc != 0) {
+error_exit(rc, __func__);
+}
+}
+pthread_mutex_unlock(&sem->lock);
+return (rc == ETIMEDOUT ? -1 : 0);
+#else
 if (ms <= 0) {
 /* This is cheaper than sem_timedwait.  */
 do {
@@ -161,15 +231,7 @@ int qemu_sem_timedwait(QemuSemaphore *sem, int ms)
 return -1;
 }
 } else {
-struct timeval tv;
-struct timespec ts;
-gettimeofday(&tv, NULL);
-ts.tv_nsec = tv.tv_usec * 1000 + (ms % 1000) * 100;
-ts.tv_sec = tv.tv_sec + ms / 1000;
-if (ts.tv_nsec >= 10) {
-ts.tv_sec++;
-ts.tv_nsec -= 10;
-}
+compute_abs_deadline(&ts, ms);
 do {
 rc = sem_timedwait(&sem->sem, &ts);
 } while (rc == -1 && errno == EINTR);
@@ -181,10 +243,19 @@ int qemu_sem_timedwait(QemuSemaphore *sem, int ms)
 error_exit(errno, __func__);
 }
 return 0;
+#endif
 }
 
 void qemu_sem_wait(QemuSemaphore *sem)
 {
+#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+pthread_mutex_lock(&sem->lock);
+--sem->count;
+while (sem->count < 0) {
+pthread_cond_wait(&sem->cond, &sem->lock);
+}
+pthread_mutex_unlock(&sem->lock);
+#else
 int rc;
 
 do {
@@ -193,6 +264,7 @@ void qemu_sem_wait(QemuSemaphore *sem)
 if (rc < 0) {
 error_exit(errno, __func__);
 }
+#endif
 }
 
 void qemu_thread_create(QemuThread *thread,
diff --git a/qemu-thread-posix.h b/qemu-thread-posix.h
index 2542c15..380bae2 100644
--- a/qemu-thread-posix.h
+++ b/qemu-thread-posix.h
@@ -12,7 +12,13 @@ struct QemuCond {
 };
 
 struct QemuSemaphore {
+#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+pthread_mutex_t lock;
+pthread_cond_t cond;
+int count;
+#else
 sem_t sem;
+#endif
 };
 
 struct QemuThread {
-- 
1.7.12.1





[Qemu-devel] [PATCH v2 1/5] compiler: support Darwin weak references

2012-11-02 Thread Paolo Bonzini
Weakrefs only tell you if the symbol was defined elsewhere, so you
need a further check at runtime to pick the default definition
when needed.

This could be automated by the compiler, but it does not do it.

Signed-off-by: Paolo Bonzini 
---
v1->v2: add unused attribute

 compiler.h |  9 -
 osdep.c| 56 
 oslib-win32.c  | 12 +++-
 qemu-sockets.c | 40 ++--
 qmp.c  |  2 ++
 5 file modificati, 71 inserzioni(+), 48 rimozioni(-)

diff --git a/compiler.h b/compiler.h
index 58865d6..55d7d74 100644
--- a/compiler.h
+++ b/compiler.h
@@ -50,8 +50,15 @@
 #   define __printf__ __gnu_printf__
 #  endif
 # endif
-# define QEMU_WEAK_ALIAS(newname, oldname) \
+# if defined(__APPLE__)
+#  define QEMU_WEAK_ALIAS(newname, oldname) \
+static typeof(oldname) weak_##newname __attribute__((unused, 
weakref(#oldname)))
+#  define QEMU_WEAK_REF(newname, oldname) (weak_##newname ? weak_##newname : 
oldname)
+# else
+#  define QEMU_WEAK_ALIAS(newname, oldname) \
 typeof(oldname) newname __attribute__((weak, alias (#oldname)))
+#  define QEMU_WEAK_REF(newname, oldname) newname
+# endif
 #else
 #define GCC_ATTR /**/
 #define GCC_FMT_ATTR(n, m)
diff --git a/osdep.c b/osdep.c
index a87d4a4..2f7a491 100644
--- a/osdep.c
+++ b/osdep.c
@@ -54,6 +54,38 @@ static bool fips_enabled = false;
 
 static const char *qemu_version = QEMU_VERSION;
 
+static int default_fdset_get_fd(int64_t fdset_id, int flags)
+{
+return -1;
+}
+QEMU_WEAK_ALIAS(monitor_fdset_get_fd, default_fdset_get_fd);
+#define monitor_fdset_get_fd \
+QEMU_WEAK_REF(monitor_fdset_get_fd, default_fdset_get_fd)
+
+static int default_fdset_dup_fd_add(int64_t fdset_id, int dup_fd)
+{
+return -1;
+}
+QEMU_WEAK_ALIAS(monitor_fdset_dup_fd_add, default_fdset_dup_fd_add);
+#define monitor_fdset_dup_fd_add \
+QEMU_WEAK_REF(monitor_fdset_dup_fd_add, default_fdset_dup_fd_add)
+
+static int default_fdset_dup_fd_remove(int dup_fd)
+{
+return -1;
+}
+QEMU_WEAK_ALIAS(monitor_fdset_dup_fd_remove, default_fdset_dup_fd_remove);
+#define monitor_fdset_dup_fd_remove \
+QEMU_WEAK_REF(monitor_fdset_dup_fd_remove, default_fdset_dup_fd_remove)
+
+static int default_fdset_dup_fd_find(int dup_fd)
+{
+return -1;
+}
+QEMU_WEAK_ALIAS(monitor_fdset_dup_fd_find, default_fdset_dup_fd_find);
+#define monitor_fdset_dup_fd_find \
+QEMU_WEAK_REF(monitor_fdset_dup_fd_remove, default_fdset_dup_fd_find)
+
 int socket_set_cork(int fd, int v)
 {
 #if defined(SOL_TCP) && defined(TCP_CORK)
@@ -400,27 +432,3 @@ bool fips_get_state(void)
 return fips_enabled;
 }
 
-
-static int default_fdset_get_fd(int64_t fdset_id, int flags)
-{
-return -1;
-}
-QEMU_WEAK_ALIAS(monitor_fdset_get_fd, default_fdset_get_fd);
-
-static int default_fdset_dup_fd_add(int64_t fdset_id, int dup_fd)
-{
-return -1;
-}
-QEMU_WEAK_ALIAS(monitor_fdset_dup_fd_add, default_fdset_dup_fd_add);
-
-static int default_fdset_dup_fd_remove(int dup_fd)
-{
-return -1;
-}
-QEMU_WEAK_ALIAS(monitor_fdset_dup_fd_remove, default_fdset_dup_fd_remove);
-
-static int default_fdset_dup_fd_find(int dup_fd)
-{
-return -1;
-}
-QEMU_WEAK_ALIAS(monitor_fdset_dup_fd_find, default_fdset_dup_fd_find);
diff --git a/oslib-win32.c b/oslib-win32.c
index 9ca83df..326a2bd 100644
--- a/oslib-win32.c
+++ b/oslib-win32.c
@@ -32,6 +32,13 @@
 #include "trace.h"
 #include "qemu_socket.h"
 
+static void default_qemu_fd_register(int fd)
+{
+}
+QEMU_WEAK_ALIAS(qemu_fd_register, default_qemu_fd_register);
+#define qemu_fd_register \
+QEMU_WEAK_REF(qemu_fd_register, default_qemu_fd_register)
+
 void *qemu_oom_check(void *ptr)
 {
 if (ptr == NULL) {
@@ -150,8 +157,3 @@ int qemu_get_thread_id(void)
 {
 return GetCurrentThreadId();
 }
-
-static void default_qemu_fd_register(int fd)
-{
-}
-QEMU_WEAK_ALIAS(qemu_fd_register, default_qemu_fd_register);
diff --git a/qemu-sockets.c b/qemu-sockets.c
index f2a6371..abcd791 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -61,6 +61,28 @@ static QemuOptsList dummy_opts = {
 },
 };
 
+static int default_monitor_get_fd(Monitor *mon, const char *name, Error **errp)
+{
+error_setg(errp, "only QEMU supports file descriptor passing");
+return -1;
+}
+QEMU_WEAK_ALIAS(monitor_get_fd, default_monitor_get_fd);
+#define monitor_get_fd \
+QEMU_WEAK_REF(monitor_get_fd, default_monitor_get_fd)
+
+static int default_qemu_set_fd_handler2(int fd,
+IOCanReadHandler *fd_read_poll,
+IOHandler *fd_read,
+IOHandler *fd_write,
+void *opaque)
+
+{
+abort();
+}
+QEMU_WEAK_ALIAS(qemu_set_fd_handler2, default_qemu_set_fd_handler2);
+#define qemu_set_fd_handler2 \
+QEMU_WEAK_REF(qemu_set_fd_handler2, default_qemu_set_fd_handler2)
+
 static int inet_getport(struct addrinfo *e)
 {
 struct sock

[Qemu-devel] [PATCH v2 0/5] Fixes for thread pool patches.

2012-11-02 Thread Paolo Bonzini
Three fixes: 1) Darwin does not support weak aliases, use weak
references instead.  2) Darwin, NetBSD and OpenBSD do not have
sem_timedwait, implement counting semaphores with a mutex and
cv there.  3) Daemonize was broken, fixes are in patches 3-5.

Paolo Bonzini (5):
  compiler: support Darwin weak references
  semaphore: implement fallback counting semaphores with mutex+condvar
  qemu-timer: reinitialize timers after fork
  vl: unify calls to init_timer_alarm
  vl: delay thread initialization after daemonization

 compiler.h  |  9 +-
 main-loop.c |  6 ++--
 osdep.c | 56 ++--
 oslib-win32.c   | 12 ---
 qemu-sockets.c  | 40 ---
 qemu-thread-posix.c | 92 +++--
 qemu-thread-posix.h |  6 
 qemu-timer.c| 14 
 qmp.c   |  2 ++
 vl.c|  9 ++
 10 file modificati, 180 inserzioni(+), 66 rimozioni(-)

-- 
1.7.12.1




Re: [Qemu-devel] [PATCHv2 1/4] Adding new syscalls (bugzilla 855162)

2012-11-02 Thread Paul Moore
On Friday, November 02, 2012 10:10:02 AM Paul Moore wrote:
> On Friday, November 02, 2012 09:48:55 AM Corey Bryant wrote:
> > On 11/01/2012 05:43 PM, Paul Moore wrote:
> > > On Tuesday, October 23, 2012 03:55:29 AM Eduardo Otubo wrote:
> > >> According to the bug 855162[0] - there's the need of adding new
> > >> syscalls
> > >> to the whitelist whenn using Qemu with Libvirt.
> > >> 
> > >> [0] - https://bugzilla.redhat.com/show_bug.cgi?id=855162
> > >> 
> > >> v2: Adding new syscalls to the list: readlink, rt_sigpending, and
> > >> 
> > >>  rt_sigtimedwait
> > >> 
> > >> Reported-by: Paul Moore 
> > >> Signed-off-by: Eduardo Otubo 
> > >> ---
> > >> 
> > >>   qemu-seccomp.c | 13 -
> > >>   1 file changed, 12 insertions(+), 1 deletion(-)
> > > 
> > > I had an opportunity to test this patchset on a F17 machine using QEMU
> > > 1.2
> > > and unfortunately it still fails.  I'm using a relatively basic guest
> > > configuration running F16, the details are documented in the RH BZ that
> > > Eduardo mentioned in the patch description.
> > 
> > Paul, Here's the latest diff for the whitelist.  We're looking to get
> > the patches out in the next few days after a bit more testing.
> 
> Okay, thanks for the updated list ... I'm rebuilding QEMU right now and I'll
> report back with the results later today.

Sadly, no luck, it still fails.

-- 
paul moore
security and virtualization @ redhat




Re: [Qemu-devel] RBD trim / unmap support?

2012-11-02 Thread Stefan Priebe - Profihost AG

Hello qemu list,

i cc you as i'm not sure where the problem is.

When i use scsi-hd with discard_granularity the discard works fine on 
target size but the client print these - immediatly after sending 
discard / trim commands with mkfs.btrfs.

[   75.076895] sd 2:0:0:4: [sdc]
[   75.078353] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[   75.079377] sd 2:0:0:4: [sdc]
[   75.080410] Sense Key : Aborted Command [current]
[   75.081446] sd 2:0:0:4: [sdc]
[   75.082459] Add. Sense: I/O process terminated
[   75.083466] sd 2:0:0:4: [sdc] CDB:
[   75.084473] Write same(16): 93 08 00 00 00 00 00 00 00 00 00 7f ff ff
00 00
[   75.085535] end_request: I/O error, dev sdc, sector 0
[   75.086567] sd 2:0:0:4: [sdc]
[   75.087569] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[   75.088605] sd 2:0:0:4: [sdc]
[   75.089610] Sense Key : Aborted Command [current]
[   75.090630] sd 2:0:0:4: [sdc]
[   75.091631] Add. Sense: I/O process terminated
[   75.092621] sd 2:0:0:4: [sdc] CDB:
[   75.093579] Write same(16): 93 08 00 00 00 00 00 7f ff ff 00 7f ff ff
00 00
[   75.094581] end_request: I/O error, dev sdc, sector 8388607
[   75.095558] sd 2:0:0:4: [sdc]
[   75.096561] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[   75.097553] sd 2:0:0:4: [sdc]
[   75.098520] Sense Key : Aborted Command [current]
[   75.099484] sd 2:0:0:4: [sdc]
[   75.100471] Add. Sense: I/O process terminated
[   75.101439] sd 2:0:0:4: [sdc] CDB:
[   75.102432] Write same(16): 93 08 00 00 00 00 00 ff ff fe 00 7f ff ff
00 00
[   75.103464] end_request: I/O error, dev sdc, sector 16777214
[   75.104503] sd 2:0:0:4: [sdc]
[   75.105507] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[   75.106514] sd 2:0:0:4: [sdc]
[   75.107525] Sense Key : Aborted Command [current]
[   75.108545] sd 2:0:0:4: [sdc]
[   75.109525] Add. Sense: I/O process terminated
[   75.110487] sd 2:0:0:4: [sdc] CDB:
[   75.111418] Write same(16): 93 08 00 00 00 00 01 7f ff fd 00 7f ff ff
00 00
[   75.112419] end_request: I/O error, dev sdc, sector 25165821
[   75.238627] sd 2:0:0:4: [sdc]
[   75.239946] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[   75.241197] sd 2:0:0:4: [sdc]
[   75.242097] Sense Key : Aborted Command [current]
[   75.242627] sd 2:0:0:4: [sdc]
[   75.242627] Add. Sense: I/O process terminated
[   75.242627] sd 2:0:0:4: [sdc] CDB:
[   75.242627] Write same(16): 93 08 00 00 00 00 01 ff ff fc 00 7f ff ff
00 00
[   75.242627] end_request: I/O error, dev sdc, sector 33554428
[   75.447311] sd 2:0:0:4: [sdc]
[   75.448505] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[   75.449392] sd 2:0:0:4: [sdc]
[   75.450262] Sense Key : Aborted Command [current]
[   75.451134] sd 2:0:0:4: [sdc]
[   75.451312] Add. Sense: I/O process terminated
[   75.451312] sd 2:0:0:4: [sdc] CDB:
[   75.451312] Write same(16): 93 08 00 00 00 00 02 7f ff fb 00 7f ff ff
00 00
[   75.451312] end_request: I/O error, dev sdc, sector 41943035
[   75.476364] sd 2:0:0:4: [sdc]
[   75.477252] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[   75.478135] sd 2:0:0:4: [sdc]
[   75.479004] Sense Key : Aborted Command [current]
[   75.479891] sd 2:0:0:4: [sdc]
[   75.480358] Add. Sense: I/O process terminated
[   75.480358] sd 2:0:0:4: [sdc] CDB:
[   75.480358] Write same(16): 93 08 00 00 00 00 02 ff ff fa 00 7f ff ff
00 00
[   75.480358] end_request: I/O error, dev sdc, sector 50331642
[   75.496374] sd 2:0:0:4: [sdc]
[   75.497202] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[   75.498077] sd 2:0:0:4: [sdc]
[   75.498948] Sense Key : Aborted Command [current]
[   75.499818] sd 2:0:0:4: [sdc]
[   75.500374] Add. Sense: I/O process terminated
[   75.500374] sd 2:0:0:4: [sdc] CDB:
[   75.500374] Write same(16): 93 08 00 00 00 00 03 7f ff f9 00 7f ff ff
00 00
[   75.500374] end_request: I/O error, dev sdc, sector 58720249

Stefan

Am 02.11.2012 09:20, schrieb Stefan Priebe - Profihost AG:

Am 02.11.2012 00:36, schrieb Josh Durgin:

On 11/01/2012 04:33 PM, Stefan Priebe wrote:

Hello list,

does rbd support trim / unmap? Or is it planned to support it?

Greets,
Stefan


librbd (and thus qemu) support it. The rbd kernel module does not yet.
See http://ceph.com/docs/master/rbd/qemu-rbd/#enabling-discard-trim


Thanks! Is there any recommanded value for discard_granularity? With
fstrim and iscsi i use 128kb.





Stefan




Re: [Qemu-devel] [PATCHv2 1/4] Adding new syscalls (bugzilla 855162)

2012-11-02 Thread Paul Moore
On Friday, November 02, 2012 12:29:37 AM Eduardo Otubo wrote:
> On Thu, Nov 01, 2012 at 05:43:03PM -0400, Paul Moore wrote:
> > On Tuesday, October 23, 2012 03:55:29 AM Eduardo Otubo wrote:
> > > According to the bug 855162[0] - there's the need of adding new syscalls
> > > to the whitelist whenn using Qemu with Libvirt.
> > > 
> > > [0] - https://bugzilla.redhat.com/show_bug.cgi?id=855162
> > > 
> > > v2: Adding new syscalls to the list: readlink, rt_sigpending, and
> > > 
> > > rt_sigtimedwait
> > > 
> > > Reported-by: Paul Moore 
> > > Signed-off-by: Eduardo Otubo 
> > > ---
> > > 
> > >  qemu-seccomp.c | 13 -
> > >  1 file changed, 12 insertions(+), 1 deletion(-)
> > 
> > I had an opportunity to test this patchset on a F17 machine using QEMU 1.2
> > and unfortunately it still fails.  I'm using a relatively basic guest
> > configuration running F16, the details are documented in the RH BZ that
> > Eduardo mentioned in the patch description.
> > 
> > Eduardo, I assume you are not able to reproduce this?
> 
> Unfortunately no. But we have the v3  patchset coming soon with new
> syscalls and we're hoping to get this fixed. Thanks for the feedback
> Paul!

No problem, thanks for all your work on this patchset.

-- 
paul moore
security and virtualization @ redhat




Re: [Qemu-devel] [PATCHv2 1/4] Adding new syscalls (bugzilla 855162)

2012-11-02 Thread Paul Moore
On Friday, November 02, 2012 09:48:55 AM Corey Bryant wrote:
> On 11/01/2012 05:43 PM, Paul Moore wrote:
> > On Tuesday, October 23, 2012 03:55:29 AM Eduardo Otubo wrote:
> >> According to the bug 855162[0] - there's the need of adding new syscalls
> >> to the whitelist whenn using Qemu with Libvirt.
> >> 
> >> [0] - https://bugzilla.redhat.com/show_bug.cgi?id=855162
> >> 
> >> v2: Adding new syscalls to the list: readlink, rt_sigpending, and
> >> 
> >>  rt_sigtimedwait
> >> 
> >> Reported-by: Paul Moore 
> >> Signed-off-by: Eduardo Otubo 
> >> ---
> >> 
> >>   qemu-seccomp.c | 13 -
> >>   1 file changed, 12 insertions(+), 1 deletion(-)
> > 
> > I had an opportunity to test this patchset on a F17 machine using QEMU 1.2
> > and unfortunately it still fails.  I'm using a relatively basic guest
> > configuration running F16, the details are documented in the RH BZ that
> > Eduardo mentioned in the patch description.
> 
> Paul, Here's the latest diff for the whitelist.  We're looking to get
> the patches out in the next few days after a bit more testing.

Okay, thanks for the updated list ... I'm rebuilding QEMU right now and I'll 
report back with the results later today.

-- 
paul moore
security and virtualization @ redhat




[Qemu-devel] First 9 + 1/2 years of QEMU dev history animated

2012-11-02 Thread Daniel P. Berrange
While I was generating an animation of libvirt dev history[1] using gource,
I also took the time to generate one showing the first 9+1/2 years of
QEMU's dev history.

  https://www.youtube.com/watch?v=IujBYP7cw8E

I see QEMU has its 10th birthday coming up early next year on Feb 18, 2013,
assuming the imported cvs->svn->git history dates are correct:

  commit e63c3dc74bfb90e4522d075d0d5a7600c5145745
  Author: (no author) <(no author)@c046a42c-6fe2-441c-8c8c-71466251a162>
  Date:   Tue Feb 18 22:55:36 2003 +

Standard project directories initialized by cvs2svn.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1 
c046a42c-6fe2-441c-8c8c-71466251a162

Regards,
Daniel

[1] https://www.youtube.com/watch?v=TKynN8TwC0M
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|



Re: [Qemu-devel] [PATCH 2/5] semaphore: implement fallback counting semaphores with mutex+condvar

2012-11-02 Thread Peter Maydell
On 2 November 2012 14:14, Paolo Bonzini  wrote:
> +#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
> +struct timespec ts;
> +clock_gettime(CLOCK_REALTIME, &ts);


qemu-thread-posix.c:198:5: warning: implicit declaration of function
'clock_gettime' is invalid in C99
  [-Wimplicit-function-declaration]
clock_gettime(CLOCK_REALTIME, &ts);
^
qemu-thread-posix.c:198:19: error: use of undeclared identifier 'CLOCK_REALTIME'
clock_gettime(CLOCK_REALTIME, &ts);
  ^
1 warning and 1 error generated.
make: *** [qemu-thread-posix.o] Error 1

MacOS doesn't implement clock_gettime()...

-- PMM



Re: [Qemu-devel] [PATCHv2 1/4] Adding new syscalls (bugzilla 855162)

2012-11-02 Thread Corey Bryant



On 11/01/2012 05:43 PM, Paul Moore wrote:

On Tuesday, October 23, 2012 03:55:29 AM Eduardo Otubo wrote:

According to the bug 855162[0] - there's the need of adding new syscalls
to the whitelist whenn using Qemu with Libvirt.

[0] - https://bugzilla.redhat.com/show_bug.cgi?id=855162

v2: Adding new syscalls to the list: readlink, rt_sigpending, and
 rt_sigtimedwait

Reported-by: Paul Moore 
Signed-off-by: Eduardo Otubo 
---
  qemu-seccomp.c | 13 -
  1 file changed, 12 insertions(+), 1 deletion(-)


I had an opportunity to test this patchset on a F17 machine using QEMU 1.2 and
unfortunately it still fails.  I'm using a relatively basic guest
configuration running F16, the details are documented in the RH BZ that
Eduardo mentioned in the patch description.


Paul, Here's the latest diff for the whitelist.  We're looking to get 
the patches out in the next few days after a bit more testing.


diff --git a/qemu-seccomp.c b/qemu-seccomp.c
index 64329a3..81aaf74 100644
--- a/qemu-seccomp.c
+++ b/qemu-seccomp.c
@@ -45,6 +45,12 @@ static const struct QemuSeccompSyscall 
seccomp_whitelist[] = {

 { SCMP_SYS(access), 245 },
 { SCMP_SYS(prctl), 245 },
 { SCMP_SYS(signalfd), 245 },
+{ SCMP_SYS(getrlimit), 245 },
+{ SCMP_SYS(set_tid_address), 245 },
+{ SCMP_SYS(socketpair), 245 },
+{ SCMP_SYS(statfs), 245 },
+{ SCMP_SYS(unlink), 245 },
+{ SCMP_SYS(wait4), 245 },
 #if defined(__i386__)
 { SCMP_SYS(fcntl64), 245 },
 { SCMP_SYS(fstat64), 245 },
@@ -59,6 +65,8 @@ static const struct QemuSeccompSyscall 
seccomp_whitelist[] = {

 { SCMP_SYS(mmap2), 245},
 { SCMP_SYS(sigprocmask), 245 },
 #elif defined(__x86_64__)
+{ SCMP_SYS(semget), 245},
+#endif
 { SCMP_SYS(sched_getparam), 245},
 { SCMP_SYS(sched_getscheduler), 245},
 { SCMP_SYS(fstat), 245},
@@ -69,11 +77,15 @@ static const struct QemuSeccompSyscall 
seccomp_whitelist[] = {

 { SCMP_SYS(socket), 245},
 { SCMP_SYS(setsockopt), 245},
 { SCMP_SYS(uname), 245},
-{ SCMP_SYS(semget), 245},
-#endif
 { SCMP_SYS(eventfd2), 245 },
 { SCMP_SYS(dup), 245 },
+{ SCMP_SYS(dup2), 245 },
+{ SCMP_SYS(dup3), 245 },
 { SCMP_SYS(gettid), 245 },
+{ SCMP_SYS(getgid), 245 },
+{ SCMP_SYS(getegid), 245 },
+{ SCMP_SYS(getuid), 245 },
+{ SCMP_SYS(geteuid), 245 },
 { SCMP_SYS(timer_create), 245 },
 { SCMP_SYS(exit), 245 },
 { SCMP_SYS(clock_gettime), 245 },
@@ -107,7 +119,22 @@ static const struct QemuSeccompSyscall 
seccomp_whitelist[] = {

 { SCMP_SYS(getsockname), 242 },
 { SCMP_SYS(getpeername), 242 },
 { SCMP_SYS(fdatasync), 242 },
-{ SCMP_SYS(close), 242 }
+{ SCMP_SYS(close), 242 },
+{ SCMP_SYS(accept4), 242 },
+{ SCMP_SYS(rt_sigpending), 242 },
+{ SCMP_SYS(rt_sigtimedwait), 242 },
+{ SCMP_SYS(readv), 242 },
+{ SCMP_SYS(writev), 242 },
+{ SCMP_SYS(preadv), 242 },
+{ SCMP_SYS(pwritev), 242 },
+{ SCMP_SYS(setrlimit), 242 },
+{ SCMP_SYS(ftruncate), 242 },
+{ SCMP_SYS(lstat), 242 },
+{ SCMP_SYS(pipe), 242 },
+{ SCMP_SYS(umask), 242 },
+{ SCMP_SYS(chdir), 242 },
+{ SCMP_SYS(setitimer), 242 },
+{ SCMP_SYS(setsid), 242 }
 };

Regards,
Corey Bryant




Re: [Qemu-devel] [PATCH 1/5] compiler: support Darwin weak references

2012-11-02 Thread Peter Maydell
On 2 November 2012 14:14, Paolo Bonzini  wrote:
> Weakrefs only tell you if the symbol was defined elsewhere, so you
> need a further check at runtime to pick the default definition
> when needed.
>
> This could be automated by the compiler, but it does not do it.

clang doesn't error out anymore, but this version still provokes
a warning:

  CCosdep.o
osdep.c:85:1: warning: unused function
'weak_monitor_fdset_dup_fd_find' [-Wunused-function]
QEMU_WEAK_ALIAS(monitor_fdset_dup_fd_find, default_fdset_dup_fd_find);
^
./compiler.h:55:32: note: expanded from macro 'QEMU_WEAK_ALIAS'
static typeof(oldname) weak_##newname __attribute__((weakref(#oldname)))
   ^
:147:1: note: expanded from macro 'weak_'
weak_monitor_fdset_dup_fd_find
^
1 warning generated.

-- PMM



Re: [Qemu-devel] buildbot failure in qemu on default_i386_macosx

2012-11-02 Thread Corey Bryant



On 11/02/2012 03:17 AM, Stefan Hajnoczi wrote:

Corey, any ideas here?



My guess for the majority of these is that monitor.o is not being linked 
with osdep.o for MacOSX.  Is this a nightly build that would have been 
successful earlier in the week?  Also do you know if (and perhaps how) I 
can cross compile on Fedora to recreate this?


--
Regards,
Corey Bryant


   LINK  qemu-ga
Undefined symbols:
   "_monitor_get_fd", referenced from:
   _socket_connect in qemu-sockets.o
   _socket_listen in qemu-sockets.o
   "_monitor_fdset_dup_fd_find", referenced from:
   _qemu_close in osdep.o
   "_sem_timedwait", referenced from:
   _qemu_sem_timedwait in qemu-thread-posix.o
   "_monitor_fdset_dup_fd_remove", referenced from:
   _qemu_close in osdep.o
   "_monitor_fdset_get_fd", referenced from:
   _qemu_open in osdep.o
   "_qemu_set_fd_handler2", referenced from:
   _inet_connect_addr in qemu-sockets.o
   _wait_for_connect in qemu-sockets.o
   _unix_connect_opts in qemu-sockets.o
   "_monitor_fdset_dup_fd_add", referenced from:
   _qemu_open in osdep.o
ld: symbol(s) not found

On Fri, Nov 2, 2012 at 5:01 AM,   wrote:

The Buildbot has detected a new failure on builder default_i386_macosx while 
building qemu.
Full details are available at:
  http://buildbot.b1-systems.de/qemu/builders/default_i386_macosx/builds/2

Buildbot URL: http://buildbot.b1-systems.de/qemu/

Buildslave for this Build: MacOSX-10.5

Build Reason: The Nightly scheduler named 'nightly_default_5oclock' triggered 
this build
Build Source Stamp: [branch master] HEAD
Blamelist:

BUILD FAILED: failed compile

sincerely,
  -The Buildbot








Re: [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors

2012-11-02 Thread Luiz Capitulino
On Fri, 02 Nov 2012 14:40:03 +0100
Kevin Wolf  wrote:

> Am 02.11.2012 14:25, schrieb Luiz Capitulino:
> > On Fri, 19 Oct 2012 11:27:59 -0300
> > Luiz Capitulino  wrote:
> > 
> >> By adding error propagation to bdrv_img_create() we improve error reporting
> >> in qmp_transaction() and simplify qemu-img.c:img_create() a bit.
> >>
> >> Please, check individual patches for details.
> > 
> > Kevin, is this in your review queue?
> 
> Yes, it is. With KVM Forum and lots of other patch series, no promises
> though.

Sure, just wanted to know if you were aware about it.




Re: [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors

2012-11-02 Thread Kevin Wolf
Am 02.11.2012 14:25, schrieb Luiz Capitulino:
> On Fri, 19 Oct 2012 11:27:59 -0300
> Luiz Capitulino  wrote:
> 
>> By adding error propagation to bdrv_img_create() we improve error reporting
>> in qmp_transaction() and simplify qemu-img.c:img_create() a bit.
>>
>> Please, check individual patches for details.
> 
> Kevin, is this in your review queue?

Yes, it is. With KVM Forum and lots of other patch series, no promises
though.

Kevin



Re: [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors

2012-11-02 Thread Luiz Capitulino
On Fri, 19 Oct 2012 11:27:59 -0300
Luiz Capitulino  wrote:

> By adding error propagation to bdrv_img_create() we improve error reporting
> in qmp_transaction() and simplify qemu-img.c:img_create() a bit.
> 
> Please, check individual patches for details.

Kevin, is this in your review queue?



Re: [Qemu-devel] [PATCH v2] tests: allow qemu-iotests to be run against nbd backend

2012-11-02 Thread Kevin Wolf
Am 02.11.2012 13:41, schrieb Paolo Bonzini:
> Il 02/11/2012 11:28, n...@bytemark.co.uk ha scritto:
>> @@ -197,12 +198,14 @@ testlist options
>>  IMGPROTO=rbd
>>  xpand=false
>>  ;;
>> -
>>  -sheepdog)
>>  IMGPROTO=sheepdog
>>  xpand=false
>>  ;;
>> -
>> +-nbd)
>> +IMGPROTO=nbd
>> +xpand=false
>> +;;
>>  -nocache)
> 
> Spacing problem?

Yes, tabs in the original code. Not sure how to deal best with it...

Kevin



Re: [Qemu-devel] [PATCH] add bochs dispi interface framebuffer driver

2012-11-02 Thread Gerd Hoffmann
>> Only with bochsfb or with vesafb (+ fbdev xorg driver) too?
> 
> vt-switching with vesafb/X11 works fine on a grml 64-bit image.  However, xorg
> uses vesa driver in this case, not fbdev (fbdev / fbdevhw xorg modules are
> initially loaded but then unloaded). X11 uses 1280x768 and vesafb uses 
> 1024x768
> according to dmesg. 

You should be able to force the fbdev driver using xorg.conf.

> But i haven't been able to test ubuntu+vesafb.  Ubuntu kernels use efifb
> (CONFIG_FB_EFI=y) and fbconsoles don't work at all with this driver +
> qemu/seabios/vgastd.

I think this is a grub2 setup issue.  Grub2 can pass gfx mode params to
the linux kernel in a way efifb is able to handle.

> vt7 http://picpaste.de/bochsfb-badstart-AirrXZuF.png
> vt1 http://www.picpaste.de/bochsfb-badstart-f1-EO10MVdF.png

> it still happens with the latest bochsfb driver (tested with 3.6.0 though, not
> 3.7.0-rc3 yet)

Most likely this is a guest-side bug and not specific to bochsfb.
Console switching depends on all parties being cooperative.  Nothing
stops an application writing to the framebuffer even it isn't running on
the foreground console.

cheers,
  Gerd



[Qemu-devel] [PATCH 3/5] qemu-timer: reinitialize timers after fork

2012-11-02 Thread Paolo Bonzini
Timers are not inherited by the child of a fork(2), so just use
pthread_atfork to reinstate them after daemonize.

Signed-off-by: Paolo Bonzini 
---
 qemu-timer.c | 15 ++-
 1 file modificato, 14 inserzioni(+). 1 rimozione(-)

diff --git a/qemu-timer.c b/qemu-timer.c
index f3426c9..1d87694 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -742,6 +742,17 @@ static void quit_timers(void)
 t->stop(t);
 }
 
+static void reinit_timers(void)
+{
+struct qemu_alarm_timer *t = alarm_timer;
+t->stop(t);
+if (t->start(t)) {
+fprintf(stderr, "Internal timer error: aborting\n");
+exit(1);
+}
+qemu_rearm_alarm_timer(t);
+}
+
 int init_timer_alarm(void)
 {
 struct qemu_alarm_timer *t = NULL;
@@ -765,6 +776,9 @@ int init_timer_alarm(void)
 }
 
 atexit(quit_timers);
+#ifdef CONFIG_POSIX
+pthread_atfork(NULL, NULL, reinit_timers);
+#endif
 alarm_timer = t;
 return 0;
 
-- 
1.7.12.1





[Qemu-devel] [PATCH 5/5] vl: delay thread initialization after daemonization

2012-11-02 Thread Paolo Bonzini
Commit ac4119c (chardev: Use timer instead of bottom-half to postpone
open event, 2012-10-12) moved the alarm timer initialization to an earlier
point but failed to consider that it depends on qemu_init_main_loop.

Later, commit 1c53786 (vl: init main loop earlier, 2012-10-30) fixed
this, but left -daemonize in two different ways.  First, timers need to
be reinitialized after forking.  Second, the global mutex was being held
by the parent, and thus dropped after forking.

The first is now fixed using pthread_atfork.  For the second part,
make sure that the global mutex is not taken before daemonization,
and similarly delay qemu_thread_self.

Signed-off-by: Paolo Bonzini 
---
 main-loop.c | 1 -
 vl.c| 4 +++-
 2 file modificati, 3 inserzioni(+), 2 rimozioni(-)

diff --git a/main-loop.c b/main-loop.c
index 234a313..c87624e 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -128,7 +128,6 @@ int qemu_init_main_loop(void)
 exit(1);
 }
 
-qemu_mutex_lock_iothread();
 ret = qemu_signal_init();
 if (ret) {
 return ret;
diff --git a/vl.c b/vl.c
index e2d5276..0f5b07b 100644
--- a/vl.c
+++ b/vl.c
@@ -3477,7 +3477,6 @@ int main(int argc, char **argv, char **envp)
 }
 loc_set_none();
 
-qemu_init_cpu_loop();
 if (qemu_init_main_loop()) {
 fprintf(stderr, "qemu_init_main_loop failed\n");
 exit(1);
@@ -3677,6 +3676,9 @@ int main(int argc, char **argv, char **envp)
 
 os_set_line_buffering();
 
+qemu_init_cpu_loop();
+qemu_mutex_lock_iothread();
+
 #ifdef CONFIG_SPICE
 /* spice needs the timers to be initialized by this point */
 qemu_spice_init();
-- 
1.7.12.1




[Qemu-devel] [PATCH 2/5] semaphore: implement fallback counting semaphores with mutex+condvar

2012-11-02 Thread Paolo Bonzini
OpenBSD and Darwin do not have sem_timedwait.  Implement a fallback
for them.

Signed-off-by: Paolo Bonzini 
---
 qemu-thread-posix.c | 74 +
 qemu-thread-posix.h |  6 +
 2 file modificati, 80 inserzioni(+)

diff --git a/qemu-thread-posix.c b/qemu-thread-posix.c
index 6a3d3a1..048db8f 100644
--- a/qemu-thread-posix.c
+++ b/qemu-thread-posix.c
@@ -122,36 +122,100 @@ void qemu_sem_init(QemuSemaphore *sem, int init)
 {
 int rc;
 
+#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+rc = pthread_mutex_init(&sem->lock, NULL);
+if (rc != 0) {
+error_exit(rc, __func__);
+}
+rc = pthread_cond_init(&sem->cond, NULL);
+if (rc != 0) {
+error_exit(rc, __func__);
+}
+if (init < 0) {
+error_exit(EINVAL, __func__);
+}
+sem->count = init;
+#else
 rc = sem_init(&sem->sem, 0, init);
 if (rc < 0) {
 error_exit(errno, __func__);
 }
+#endif
 }
 
 void qemu_sem_destroy(QemuSemaphore *sem)
 {
 int rc;
 
+#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+rc = pthread_cond_destroy(&sem->cond);
+if (rc < 0) {
+error_exit(rc, __func__);
+}
+rc = pthread_mutex_destroy(&sem->lock);
+if (rc < 0) {
+error_exit(rc, __func__);
+}
+#else
 rc = sem_destroy(&sem->sem);
 if (rc < 0) {
 error_exit(errno, __func__);
 }
+#endif
 }
 
 void qemu_sem_post(QemuSemaphore *sem)
 {
 int rc;
 
+#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+pthread_mutex_lock(&sem->lock);
+if (sem->count == INT_MAX) {
+rc = EINVAL;
+} else if (sem->count++ < 0) {
+rc = pthread_cond_signal(&sem->cond);
+} else {
+rc = 0;
+}
+pthread_mutex_unlock(&sem->lock);
+if (rc != 0) {
+error_exit(rc, __func__);
+}
+#else
 rc = sem_post(&sem->sem);
 if (rc < 0) {
 error_exit(errno, __func__);
 }
+#endif
 }
 
 int qemu_sem_timedwait(QemuSemaphore *sem, int ms)
 {
 int rc;
 
+#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+struct timespec ts;
+clock_gettime(CLOCK_REALTIME, &ts);
+if (ms) {
+int nsec = ts.tv_nsec + (ms % 1000) * 100;
+ts.tv_sec += ms / 1000 + nsec / 10;
+ts.tv_nsec = nsec % 10;
+}
+
+pthread_mutex_lock(&sem->lock);
+--sem->count;
+while (sem->count < 0) {
+rc = pthread_cond_timedwait(&sem->cond, &sem->lock, &ts);
+if (rc == ETIMEDOUT) {
+break;
+}
+if (rc != 0) {
+error_exit(rc, __func__);
+}
+}
+pthread_mutex_unlock(&sem->lock);
+return (rc == ETIMEDOUT ? -1 : 0);
+#else
 if (ms <= 0) {
 /* This is cheaper than sem_timedwait.  */
 do {
@@ -181,10 +245,19 @@ int qemu_sem_timedwait(QemuSemaphore *sem, int ms)
 error_exit(errno, __func__);
 }
 return 0;
+#endif
 }
 
 void qemu_sem_wait(QemuSemaphore *sem)
 {
+#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+pthread_mutex_lock(&sem->lock);
+--sem->count;
+while (sem->count < 0) {
+pthread_cond_wait(&sem->cond, &sem->lock);
+}
+pthread_mutex_unlock(&sem->lock);
+#else
 int rc;
 
 do {
@@ -193,6 +266,7 @@ void qemu_sem_wait(QemuSemaphore *sem)
 if (rc < 0) {
 error_exit(errno, __func__);
 }
+#endif
 }
 
 void qemu_thread_create(QemuThread *thread,
diff --git a/qemu-thread-posix.h b/qemu-thread-posix.h
index 2542c15..1c098c2 100644
--- a/qemu-thread-posix.h
+++ b/qemu-thread-posix.h
@@ -12,7 +12,13 @@ struct QemuCond {
 };
 
 struct QemuSemaphore {
+#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+pthread_mutex_t lock;
+pthread_cond_t cond;
+int count;
+#else
 sem_t sem;
+#endif
 };
 
 struct QemuThread {
-- 
1.7.12.1





  1   2   >