Re: [PATCH 1/3] kvm tools: Lock job_mutex before signalling

2011-05-01 Thread Pekka Enberg
On Sat, 2011-04-30 at 16:30 +0300, Sasha Levin wrote:
 Locking mutex before signalling to prevent unexpected
 scheduling.
 
 Signed-off-by: Sasha Levin levinsasha...@gmail.com

Yeah, I think we need to do this but the changelog is not really
adequate for this kind of change. Care to elaborate more why it's
needed?

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] kvm tools: Lock job_mutex before signalling

2011-05-01 Thread Sasha Levin
On Sun, 2011-05-01 at 10:10 +0300, Pekka Enberg wrote:
 On Sat, 2011-04-30 at 16:30 +0300, Sasha Levin wrote:
  Locking mutex before signalling to prevent unexpected
  scheduling.
  
  Signed-off-by: Sasha Levin levinsasha...@gmail.com
 
 Yeah, I think we need to do this but the changelog is not really
 adequate for this kind of change. Care to elaborate more why it's
 needed?
 

By holding the mutex while signaling, we can expect predictable
scheduling between the worker threads. This will make debugging various
thread pool related issues much easier (and maybe solve some obscure
bugs too).

-- 

Sasha.

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 3/3] KVM: MMU: Optimize guest page table walk

2011-05-01 Thread Avi Kivity

On 04/29/2011 07:05 PM, Andi Kleen wrote:

  Do you think the following case would not differ so much
  from (1' 2') ?

  walk_addr_generic()  ---1''
copy_from_user()   ---2''

Yes it should be the same and is cleaner.

If you do a make .../foo.i and look at the code coming out of the
preprocessor you'll see it expands to a

if (!__builtin_constant_p(size))
 return copy_user_generic(dst, (__force void *)src, size);
 switch (size) {
 case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
   ret, b, b, =q, 1);
 return ret;
case 2: ..
case 4: ..
case 8: ..
case 10: ..
case 16: ..
}

Ok it looks like the 32bit kernel only handles 1/2/4. Maybe that
was the problem if you ran on 32bit.


I'm happy with a slower copy_from_user() for that particular case.

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/6] KVM: x86 emulator: Unused opt removal and some cleanups

2011-05-01 Thread Takuya Yoshikawa
Patches 0-4: Just remove unused opt
Patch 5: grpX emulation cleanup
Patch 6: jmp far emulation cleanup

Some functions introduced in patch 5/6 will be called by
opcode::execute later.

Takuya
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] KVM: x86 emulator: Remove unused opt from seg_override()

2011-05-01 Thread Takuya Yoshikawa
From: Takuya Yoshikawa yoshikawa.tak...@oss.ntt.co.jp

In addition, one comma at the end of a statement is replaced with a
semicolon.

Signed-off-by: Takuya Yoshikawa yoshikawa.tak...@oss.ntt.co.jp
---
 arch/x86/kvm/emulate.c |7 +++
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index a8faf8d..1545092 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -500,7 +500,6 @@ static unsigned long seg_base(struct x86_emulate_ctxt *ctxt,
 }
 
 static unsigned seg_override(struct x86_emulate_ctxt *ctxt,
-struct x86_emulate_ops *ops,
 struct decode_cache *c)
 {
if (!c-has_seg_override)
@@ -3527,7 +3526,7 @@ done_prefixes:
if (!c-has_seg_override)
set_seg_override(c, VCPU_SREG_DS);
 
-   memop.addr.mem.seg = seg_override(ctxt, ops, c);
+   memop.addr.mem.seg = seg_override(ctxt, c);
 
if (memop.type == OP_MEM  c-ad_bytes != 8)
memop.addr.mem.ea = (u32)memop.addr.mem.ea;
@@ -3587,7 +3586,7 @@ done_prefixes:
c-src.bytes = (c-d  ByteOp) ? 1 : c-op_bytes;
c-src.addr.mem.ea =
register_address(c, c-regs[VCPU_REGS_RSI]);
-   c-src.addr.mem.seg = seg_override(ctxt, ops, c),
+   c-src.addr.mem.seg = seg_override(ctxt, c);
c-src.val = 0;
break;
case SrcImmFAddr:
@@ -4103,7 +4102,7 @@ writeback:
c-dst.type = saved_dst_type;
 
if ((c-d  SrcMask) == SrcSI)
-   string_addr_inc(ctxt, seg_override(ctxt, ops, c),
+   string_addr_inc(ctxt, seg_override(ctxt, c),
VCPU_REGS_RSI, c-src);
 
if ((c-d  DstMask) == DstDI)
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6] KVM: x86 emulator: Remove unused opt from read_descriptor()

2011-05-01 Thread Takuya Yoshikawa
From: Takuya Yoshikawa yoshikawa.tak...@oss.ntt.co.jp

Signed-off-by: Takuya Yoshikawa yoshikawa.tak...@oss.ntt.co.jp
---
 arch/x86/kvm/emulate.c |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 1545092..72b268e 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -729,7 +729,6 @@ static void *decode_register(u8 modrm_reg, unsigned long 
*regs,
 }
 
 static int read_descriptor(struct x86_emulate_ctxt *ctxt,
-  struct x86_emulate_ops *ops,
   struct segmented_address addr,
   u16 *size, unsigned long *address, int op_bytes)
 {
@@ -2720,7 +2719,7 @@ static int em_lgdt(struct x86_emulate_ctxt *ctxt)
struct desc_ptr desc_ptr;
int rc;
 
-   rc = read_descriptor(ctxt, ctxt-ops, c-src.addr.mem,
+   rc = read_descriptor(ctxt, c-src.addr.mem,
 desc_ptr.size, desc_ptr.address,
 c-op_bytes);
if (rc != X86EMUL_CONTINUE)
@@ -2749,9 +2748,8 @@ static int em_lidt(struct x86_emulate_ctxt *ctxt)
struct desc_ptr desc_ptr;
int rc;
 
-   rc = read_descriptor(ctxt, ctxt-ops, c-src.addr.mem,
-desc_ptr.size,
-desc_ptr.address,
+   rc = read_descriptor(ctxt, c-src.addr.mem,
+desc_ptr.size, desc_ptr.address,
 c-op_bytes);
if (rc != X86EMUL_CONTINUE)
return rc;
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/6] KVM: x86 emulator: Remove unused opt from writeback()

2011-05-01 Thread Takuya Yoshikawa
From: Takuya Yoshikawa yoshikawa.tak...@oss.ntt.co.jp

Remove inline at this chance.

Signed-off-by: Takuya Yoshikawa yoshikawa.tak...@oss.ntt.co.jp
---
 arch/x86/kvm/emulate.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 72b268e..5ed358f 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1351,8 +1351,7 @@ static void write_register_operand(struct operand *op)
}
 }
 
-static inline int writeback(struct x86_emulate_ctxt *ctxt,
-   struct x86_emulate_ops *ops)
+static int writeback(struct x86_emulate_ctxt *ctxt)
 {
int rc;
struct decode_cache *c = ctxt-decode;
@@ -4089,7 +4088,7 @@ special_insn:
goto done;
 
 writeback:
-   rc = writeback(ctxt, ops);
+   rc = writeback(ctxt);
if (rc != X86EMUL_CONTINUE)
goto done;
 
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] KVM: x86 emulator: Rename emulate_grpX() to em_grpX()

2011-05-01 Thread Takuya Yoshikawa
From: Takuya Yoshikawa yoshikawa.tak...@oss.ntt.co.jp

The prototypes are changed appropriately.

We also replaces goto grp45; with simple em_grp45() call.

Signed-off-by: Takuya Yoshikawa yoshikawa.tak...@oss.ntt.co.jp
---
 arch/x86/kvm/emulate.c |   31 +++
 1 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 060f476..cd2f89d 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1687,14 +1687,14 @@ static inline int emulate_iret(struct x86_emulate_ctxt 
*ctxt,
}
 }
 
-static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt)
+static int em_grp1a(struct x86_emulate_ctxt *ctxt)
 {
struct decode_cache *c = ctxt-decode;
 
return emulate_pop(ctxt, c-dst.val, c-dst.bytes);
 }
 
-static inline void emulate_grp2(struct x86_emulate_ctxt *ctxt)
+static int em_grp2(struct x86_emulate_ctxt *ctxt)
 {
struct decode_cache *c = ctxt-decode;
switch (c-modrm_reg) {
@@ -1721,10 +1721,10 @@ static inline void emulate_grp2(struct x86_emulate_ctxt 
*ctxt)
emulate_2op_SrcB(sar, c-src, c-dst, ctxt-eflags);
break;
}
+   return X86EMUL_CONTINUE;
 }
 
-static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt,
-  struct x86_emulate_ops *ops)
+static int em_grp3(struct x86_emulate_ctxt *ctxt)
 {
struct decode_cache *c = ctxt-decode;
unsigned long *rax = c-regs[VCPU_REGS_RAX];
@@ -1763,7 +1763,7 @@ static inline int emulate_grp3(struct x86_emulate_ctxt 
*ctxt,
return X86EMUL_CONTINUE;
 }
 
-static int emulate_grp45(struct x86_emulate_ctxt *ctxt)
+static int em_grp45(struct x86_emulate_ctxt *ctxt)
 {
struct decode_cache *c = ctxt-decode;
int rc = X86EMUL_CONTINUE;
@@ -1793,8 +1793,7 @@ static int emulate_grp45(struct x86_emulate_ctxt *ctxt)
return rc;
 }
 
-static inline int emulate_grp9(struct x86_emulate_ctxt *ctxt,
-  struct x86_emulate_ops *ops)
+static int em_grp9(struct x86_emulate_ctxt *ctxt)
 {
struct decode_cache *c = ctxt-decode;
u64 old = c-dst.orig_val64;
@@ -3916,7 +3915,7 @@ special_insn:
break;
}
case 0x8f:  /* pop (sole member of Grp1a) */
-   rc = emulate_grp1a(ctxt);
+   rc = em_grp1a(ctxt);
break;
case 0x90 ... 0x97: /* nop / xchg reg, rax */
if (c-dst.addr.reg == c-regs[VCPU_REGS_RAX])
@@ -3932,7 +3931,7 @@ special_insn:
case 0xa8 ... 0xa9: /* test ax, imm */
goto test;
case 0xc0 ... 0xc1:
-   emulate_grp2(ctxt);
+   rc = em_grp2(ctxt);
break;
case 0xc3: /* ret */
c-dst.type = OP_REG;
@@ -3967,11 +3966,11 @@ special_insn:
rc = emulate_iret(ctxt, ops);
break;
case 0xd0 ... 0xd1: /* Grp2 */
-   emulate_grp2(ctxt);
+   rc = em_grp2(ctxt);
break;
case 0xd2 ... 0xd3: /* Grp2 */
c-src.val = c-regs[VCPU_REGS_RCX];
-   emulate_grp2(ctxt);
+   rc = em_grp2(ctxt);
break;
case 0xe0 ... 0xe2: /* loop/loopz/loopnz */
register_address_increment(c, c-regs[VCPU_REGS_RCX], -1);
@@ -4040,7 +4039,7 @@ special_insn:
ctxt-eflags ^= EFLG_CF;
break;
case 0xf6 ... 0xf7: /* Grp3 */
-   rc = emulate_grp3(ctxt, ops);
+   rc = em_grp3(ctxt);
break;
case 0xf8: /* clc */
ctxt-eflags = ~EFLG_CF;
@@ -4071,13 +4070,13 @@ special_insn:
ctxt-eflags |= EFLG_DF;
break;
case 0xfe: /* Grp4 */
-   grp45:
-   rc = emulate_grp45(ctxt);
+   rc = em_grp45(ctxt);
break;
case 0xff: /* Grp5 */
if (c-modrm_reg == 5)
goto jump_far;
-   goto grp45;
+   rc = em_grp45(ctxt);
+   break;
default:
goto cannot_emulate;
}
@@ -4344,7 +4343,7 @@ twobyte_insn:
(u64) c-src.val;
break;
case 0xc7:  /* Grp9 (cmpxchg8b) */
-   rc = emulate_grp9(ctxt, ops);
+   rc = em_grp9(ctxt);
break;
default:
goto cannot_emulate;
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] KVM: x86 emulator: Make jmp far emulation into a separate function

2011-05-01 Thread Takuya Yoshikawa
From: Takuya Yoshikawa yoshikawa.tak...@oss.ntt.co.jp

We introduce em_jmp_far().

We also call this from em_grp45() to stop treating modrm_reg == 5 case
separately in the group 5 emulation.

Signed-off-by: Takuya Yoshikawa yoshikawa.tak...@oss.ntt.co.jp
---
 arch/x86/kvm/emulate.c |   36 ++--
 1 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index cd2f89d..291c872 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1687,6 +1687,23 @@ static inline int emulate_iret(struct x86_emulate_ctxt 
*ctxt,
}
 }
 
+static int em_jmp_far(struct x86_emulate_ctxt *ctxt)
+{
+   struct decode_cache *c = ctxt-decode;
+   int rc;
+   unsigned short sel;
+
+   memcpy(sel, c-src.valptr + c-op_bytes, 2);
+
+   rc = load_segment_descriptor(ctxt, ctxt-ops, sel, VCPU_SREG_CS);
+   if (rc != X86EMUL_CONTINUE)
+   return rc;
+
+   c-eip = 0;
+   memcpy(c-eip, c-src.valptr, c-op_bytes);
+   return X86EMUL_CONTINUE;
+}
+
 static int em_grp1a(struct x86_emulate_ctxt *ctxt)
 {
struct decode_cache *c = ctxt-decode;
@@ -1786,6 +1803,9 @@ static int em_grp45(struct x86_emulate_ctxt *ctxt)
case 4: /* jmp abs */
c-eip = c-src.val;
break;
+   case 5: /* jmp far */
+   rc = em_jmp_far(ctxt);
+   break;
case 6: /* push */
rc = em_push(ctxt);
break;
@@ -3997,19 +4017,9 @@ special_insn:
}
case 0xe9: /* jmp rel */
goto jmp;
-   case 0xea: { /* jmp far */
-   unsigned short sel;
-   jump_far:
-   memcpy(sel, c-src.valptr + c-op_bytes, 2);
-
-   rc = load_segment_descriptor(ctxt, ops, sel, VCPU_SREG_CS);
-   if (rc != X86EMUL_CONTINUE)
-   goto done;
-
-   c-eip = 0;
-   memcpy(c-eip, c-src.valptr, c-op_bytes);
+   case 0xea: /* jmp far */
+   rc = em_jmp_far(ctxt);
break;
-   }
case 0xeb:
  jmp:  /* jmp rel short */
jmp_rel(c, c-src.val);
@@ -4073,8 +4083,6 @@ special_insn:
rc = em_grp45(ctxt);
break;
case 0xff: /* Grp5 */
-   if (c-modrm_reg == 5)
-   goto jump_far;
rc = em_grp45(ctxt);
break;
default:
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: update from 0.12.5 to 0.14 goes headless

2011-05-01 Thread Michael Tokarev
30.04.2011 16:24, Jerry Geis wrote:
 After updating when I start up no I am headless. How do I get headed
 back by default?
 
 my command is:
 qemu-system-x86_64 -net nic,model=rtl8139 -net user -hda $1 -no-acpi -m
 2048 -usb $2 $3 $4 $5 $6 -vga std

This works for me just fine with 0.14 - it displays the usual SDL
X window.

 This is now stating qemu-kvm in headless mode. it tells me to use VNC
 5901 to connect.

But when I explicitly disable SDL when compiling, it does this: it
allocates next free VNC display.

So you may check how you built it.

/mjt
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 3/3] KVM: MMU: Optimize guest page table walk

2011-05-01 Thread Andi Kleen

 Ok it looks like the 32bit kernel only handles 1/2/4. Maybe that
 was the problem if you ran on 32bit.

 I'm happy with a slower copy_from_user() for that particular case.

It wouldn't be hard to fix.

-Andi


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: State of stable 2.6.38 queue

2011-05-01 Thread Marcelo Tosatti
On Sat, Apr 30, 2011 at 01:09:31PM +0200, Jan Kiszka wrote:
 Hi,
 
 as I was about to update kvm-kmod-2.6.38, I checked for KVM changes
 since 2.6.38-rc7 which kvm-kmod is currently based on - none. That
 surprised as the update queue is non-empty. Was something lost on the
 way to stable, or are they on hold intentionally?
 
 Jan

The queue will be sent this week. 

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Livebackup feature for qemu/qemu-kvm

2011-05-01 Thread Jagane Sundar

Hello All,

I have been working on a feature called Livebackup for qemu-kvm 
(actually it is applicable to qemu). This is a feature that enables a 
system administrator or a backup program to take full and incremental 
backups of running VMs. It is explained in more detail here:


http://wiki.qemu.org/Features/Livebackup

I had initiated communication with Stefan a week or so ago regarding 
this feature and we had some discussion comparing it with two other 
proposals - Snapshot and Snapshot2.


I have further updated my documentation, and I have been testing my code 
more intensively over the last week or so. I have two git source trees 
based on qemu and qemu-kvm for this codebase. I will continue to 
maintain both till it is necessary.


At this time I would like to restart the discussion around Livebackup 
and related features.


Having a live backup feature for kvm will make it a better solution for 
IaaS clouds compared to xen. I would like to solicit feedback from all 
of you folks involved in the block subsystem of qemu. Stefan mentioned 
that Jes is the person most intimately involved in the block subsystem, 
so Jes - your feedback is particularly important.


Thanks,
Jagane
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html