[PATCH] kvm: get rid of unused label warning

2009-12-18 Thread Heiko Carstens
From: Heiko Carstens heiko.carst...@de.ibm.com

arch/s390/kvm/../../../virt/kvm/kvm_main.c: In function 'kvm_create_vm':
arch/s390/kvm/../../../virt/kvm/kvm_main.c:409: warning: label 'out_err' 
defined but not used

Signed-off-by: Heiko Carstens heiko.carst...@de.ibm.com
---

Adds even more ifdefery...

 virt/kvm/kvm_main.c |3 +++
 1 file changed, 3 insertions(+)

--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -406,8 +406,11 @@ static struct kvm *kvm_create_vm(void)
 out:
return kvm;
 
+#if defined(KVM_COALESCED_MMIO_PAGE_OFFSET) || \
+(defined(CONFIG_MMU_NOTIFIER)  defined(KVM_ARCH_WANT_MMU_NOTIFIER))
 out_err:
hardware_disable_all();
+#endif
 out_err_nodisable:
kfree(kvm);
return ERR_PTR(r);
--
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 v2] Add support for RDTSCP in VMX

2009-12-18 Thread Sheng Yang
--
regards
Yang, Sheng

 arch/x86/include/asm/kvm_host.h  |2 +
 arch/x86/include/asm/msr-index.h |1 +
 arch/x86/include/asm/msr.h   |4 +-
 arch/x86/include/asm/vmx.h   |1 +
 arch/x86/kernel/vsyscall_64.c|3 +-
 arch/x86/kvm/svm.c   |   13 +++
 arch/x86/kvm/vmx.c   |   68 +++---
 arch/x86/kvm/x86.c   |   61 +-
 8 files changed, 122 insertions(+), 31 deletions(-)

--
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: VMX: Remove redundant variable

2009-12-18 Thread Sheng Yang
It's no longer necessary.

Signed-off-by: Sheng Yang sh...@linux.intel.com
---
 arch/x86/kvm/vmx.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 9a0a2cf..5c464ed 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2383,14 +2383,12 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
for (i = 0; i  NR_VMX_MSR; ++i) {
u32 index = vmx_msr_index[i];
u32 data_low, data_high;
-   u64 data;
int j = vmx-nmsrs;
 
if (rdmsr_safe(index, data_low, data_high)  0)
continue;
if (wrmsr_safe(index, data_low, data_high)  0)
continue;
-   data = data_low | ((u64)data_high  32);
vmx-guest_msrs[j].index = i;
vmx-guest_msrs[j].data = 0;
vmx-guest_msrs[j].mask = -1ull;
-- 
1.5.4.5

--
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] x86: Add IA32_TSC_AUX MSR

2009-12-18 Thread Sheng Yang
Also replaced the hardcode value in write_tsc() and write_tscp_aux().

Signed-off-by: Sheng Yang sh...@linux.intel.com
---

(Already applied by Ingo)

 arch/x86/include/asm/msr-index.h |1 +
 arch/x86/include/asm/msr.h   |4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 4ffe09b..ac98d29 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -12,6 +12,7 @@
 #define MSR_FS_BASE0xc100 /* 64bit FS base */
 #define MSR_GS_BASE0xc101 /* 64bit GS base */
 #define MSR_KERNEL_GS_BASE 0xc102 /* SwapGS GS shadow */
+#define MSR_TSC_AUX0xc103 /* Auxiliary TSC */
 
 /* EFER bits: */
 #define _EFER_SCE  0  /* SYSCALL/SYSRET */
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index 7e2b6ba..e61fb87 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -240,9 +240,9 @@ do {
\
 #define checking_wrmsrl(msr, val) wrmsr_safe((msr), (u32)(val),
\
 (u32)((val)  32))
 
-#define write_tsc(val1, val2) wrmsr(0x10, (val1), (val2))
+#define write_tsc(val1, val2) wrmsr(MSR_IA32_TSC, (val1), (val2))
 
-#define write_rdtscp_aux(val) wrmsr(0xc103, (val), 0)
+#define write_rdtscp_aux(val) wrmsr(MSR_TSC_AUX, (val), 0)
 
 #ifdef CONFIG_SMP
 int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
-- 
1.5.4.5

--
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: Extended shared_msr_global to per CPU

2009-12-18 Thread Sheng Yang
shared_msr_global saved host value of relevant MSRs, but it have an
assumption that all MSRs it tracked shared the value across the different
CPUs. It's not true with some MSRs, e.g. MSR_TSC_AUX.

Extend it to per CPU to provide the support of MSR_TSC_AUX, and more
alike MSRs.

Notice now the shared_msr_global still have one assumption: it can only deal
with the MSRs that won't change in host after KVM module loaded.

Signed-off-by: Sheng Yang sh...@linux.intel.com
---
 arch/x86/kvm/x86.c |   55 +++
 1 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index dd15d7a..9ce7917 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -92,16 +92,16 @@ module_param_named(ignore_msrs, ignore_msrs, bool, S_IRUGO 
| S_IWUSR);
 
 struct kvm_shared_msrs_global {
int nr;
-   struct kvm_shared_msr {
-   u32 msr;
-   u64 value;
-   } msrs[KVM_NR_SHARED_MSRS];
+   u32 msrs[KVM_NR_SHARED_MSRS];
 };
 
 struct kvm_shared_msrs {
struct user_return_notifier urn;
bool registered;
-   u64 current_value[KVM_NR_SHARED_MSRS];
+   struct kvm_shared_msr_values {
+   u64 host;
+   u64 curr;
+   } values[KVM_NR_SHARED_MSRS];
 };
 
 static struct kvm_shared_msrs_global __read_mostly shared_msrs_global;
@@ -146,53 +146,64 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
 static void kvm_on_user_return(struct user_return_notifier *urn)
 {
unsigned slot;
-   struct kvm_shared_msr *global;
struct kvm_shared_msrs *locals
= container_of(urn, struct kvm_shared_msrs, urn);
+   struct kvm_shared_msr_values *values;
 
for (slot = 0; slot  shared_msrs_global.nr; ++slot) {
-   global = shared_msrs_global.msrs[slot];
-   if (global-value != locals-current_value[slot]) {
-   wrmsrl(global-msr, global-value);
-   locals-current_value[slot] = global-value;
+   values = locals-values[slot];
+   if (values-host != values-curr) {
+   wrmsrl(shared_msrs_global.msrs[slot], values-host);
+   values-curr = values-host;
}
}
locals-registered = false;
user_return_notifier_unregister(urn);
 }
 
-void kvm_define_shared_msr(unsigned slot, u32 msr)
+static void shared_msr_update(unsigned slot, u32 msr)
 {
-   int cpu;
+   struct kvm_shared_msrs *smsr;
u64 value;
 
+   smsr = __get_cpu_var(shared_msrs);
+   /* only read, and nobody should modify it at this time,
+* so don't need lock */
+   if (slot = shared_msrs_global.nr) {
+   printk(KERN_ERR kvm: invalid MSR slot!);
+   return;
+   }
+   rdmsrl_safe(msr, value);
+   smsr-values[slot].host = value;
+   smsr-values[slot].curr = value;
+}
+
+void kvm_define_shared_msr(unsigned slot, u32 msr)
+{
if (slot = shared_msrs_global.nr)
shared_msrs_global.nr = slot + 1;
-   shared_msrs_global.msrs[slot].msr = msr;
-   rdmsrl_safe(msr, value);
-   shared_msrs_global.msrs[slot].value = value;
-   for_each_online_cpu(cpu)
-   per_cpu(shared_msrs, cpu).current_value[slot] = value;
+   shared_msrs_global.msrs[slot] = msr;
+   /* we need ensured the shared_msr_global have been updated */
+   smp_wmb();
 }
 EXPORT_SYMBOL_GPL(kvm_define_shared_msr);
 
 static void kvm_shared_msr_cpu_online(void)
 {
unsigned i;
-   struct kvm_shared_msrs *locals = __get_cpu_var(shared_msrs);
 
for (i = 0; i  shared_msrs_global.nr; ++i)
-   locals-current_value[i] = shared_msrs_global.msrs[i].value;
+   shared_msr_update(i, shared_msrs_global.msrs[i]);
 }
 
 void kvm_set_shared_msr(unsigned slot, u64 value, u64 mask)
 {
struct kvm_shared_msrs *smsr = __get_cpu_var(shared_msrs);
 
-   if (((value ^ smsr-current_value[slot])  mask) == 0)
+   if (((value ^ smsr-values[slot].curr)  mask) == 0)
return;
-   smsr-current_value[slot] = value;
-   wrmsrl(shared_msrs_global.msrs[slot].msr, value);
+   smsr-values[slot].curr = value;
+   wrmsrl(shared_msrs_global.msrs[slot], value);
if (!smsr-registered) {
smsr-urn.on_user_return = kvm_on_user_return;
user_return_notifier_register(smsr-urn);
-- 
1.5.4.5

--
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 4/6] x86: Raise vsyscall priority on hotplug notifier chain

2009-12-18 Thread Sheng Yang
KVM need vsyscall_init() to initialize MSR_TSC_AUX before it read the value.
Per Avi's suggestion, this patch raised vsyscall priority on hotplug notifier
chain, to 30.

CC: Ingo Molnar mi...@elte.hu
CC: linux-ker...@vger.kernel.org
Signed-off-by: Sheng Yang sh...@linux.intel.com
---
 arch/x86/kernel/vsyscall_64.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 8cb4974..971bbc9 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -300,7 +300,8 @@ static int __init vsyscall_init(void)
register_sysctl_table(kernel_root_table2);
 #endif
on_each_cpu(cpu_vsyscall_init, NULL, 1);
-   hotcpu_notifier(cpu_vsyscall_notifier, 0);
+   /* notifier priority  KVM */
+   hotcpu_notifier(cpu_vsyscall_notifier, 30);
return 0;
 }
 
-- 
1.5.4.5

--
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: Add cpuid_update() callback to kvm_x86_ops

2009-12-18 Thread Sheng Yang
Sometime, we need to adjust some state in order to reflect guest CPUID
setting, e.g. if we don't expose rdtscp to guest, we won't want to enable
it on hardware. cpuid_update() is introduced for this purpose.

Also export kvm_find_cpuid_entry() for later use.

Signed-off-by: Sheng Yang sh...@linux.intel.com
---
 arch/x86/include/asm/kvm_host.h |1 +
 arch/x86/kvm/svm.c  |6 ++
 arch/x86/kvm/vmx.c  |6 ++
 arch/x86/kvm/x86.c  |3 +++
 4 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 4f865e8..d2a91ae 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -471,6 +471,7 @@ struct kvm_x86_ops {
int (*hardware_setup)(void);   /* __init */
void (*hardware_unsetup)(void);/* __exit */
bool (*cpu_has_accelerated_tpr)(void);
+   void (*cpuid_update)(struct kvm_vcpu *vcpu);
 
/* Create, but do not attach this VCPU */
struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm, unsigned id);
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 3de0b37..d89b0a0 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2854,6 +2854,10 @@ static u64 svm_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t 
gfn, bool is_mmio)
return 0;
 }
 
+static void svm_cpuid_update(struct kvm_vcpu *vcpu)
+{
+}
+
 static const struct trace_print_flags svm_exit_reasons_str[] = {
{ SVM_EXIT_READ_CR0,read_cr0 },
{ SVM_EXIT_READ_CR3,read_cr3 },
@@ -2978,6 +2982,8 @@ static struct kvm_x86_ops svm_x86_ops = {
 
.exit_reasons_str = svm_exit_reasons_str,
.gb_page_enable = svm_gb_page_enable,
+
+   .cpuid_update = svm_cpuid_update,
 };
 
 static int __init svm_init(void)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 5c464ed..91dff23 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3961,6 +3961,10 @@ static bool vmx_gb_page_enable(void)
return false;
 }
 
+static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
+{
+}
+
 static struct kvm_x86_ops vmx_x86_ops = {
.cpu_has_kvm_support = cpu_has_kvm_support,
.disabled_by_bios = vmx_disabled_by_bios,
@@ -4025,6 +4029,8 @@ static struct kvm_x86_ops vmx_x86_ops = {
 
.exit_reasons_str = vmx_exit_reasons_str,
.gb_page_enable = vmx_gb_page_enable,
+
+   .cpuid_update = vmx_cpuid_update,
 };
 
 static int __init vmx_init(void)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 9ce7917..e16dede 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1574,6 +1574,7 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
cpuid_fix_nx_cap(vcpu);
r = 0;
kvm_apic_set_version(vcpu);
+   kvm_x86_ops-cpuid_update(vcpu);
 
 out_free:
vfree(cpuid_entries);
@@ -1596,6 +1597,7 @@ static int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu 
*vcpu,
goto out;
vcpu-arch.cpuid_nent = cpuid-nent;
kvm_apic_set_version(vcpu);
+   kvm_x86_ops-cpuid_update(vcpu);
return 0;
 
 out:
@@ -3730,6 +3732,7 @@ struct kvm_cpuid_entry2 *kvm_find_cpuid_entry(struct 
kvm_vcpu *vcpu,
}
return best;
 }
+EXPORT_SYMBOL_GPL(kvm_find_cpuid_entry);
 
 int cpuid_maxphyaddr(struct kvm_vcpu *vcpu)
 {
-- 
1.5.4.5

--
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: VMX: Add instruction rdtscp support for guest

2009-12-18 Thread Sheng Yang
Before enabling, execution of rdtscp in guest would result in #UD.

Signed-off-by: Sheng Yang sh...@linux.intel.com
---
 arch/x86/include/asm/kvm_host.h |1 +
 arch/x86/include/asm/vmx.h  |1 +
 arch/x86/kvm/svm.c  |7 
 arch/x86/kvm/vmx.c  |   60 +--
 arch/x86/kvm/x86.c  |3 +-
 5 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index d2a91ae..07e6636 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -533,6 +533,7 @@ struct kvm_x86_ops {
int (*get_tdp_level)(void);
u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio);
bool (*gb_page_enable)(void);
+   bool (*rdtscp_supported)(void);
 
const struct trace_print_flags *exit_reasons_str;
 };
diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index 2b49454..8c39320 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -53,6 +53,7 @@
  */
 #define SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES 0x0001
 #define SECONDARY_EXEC_ENABLE_EPT   0x0002
+#define SECONDARY_EXEC_RDTSCP  0x0008
 #define SECONDARY_EXEC_ENABLE_VPID  0x0020
 #define SECONDARY_EXEC_WBINVD_EXITING  0x0040
 #define SECONDARY_EXEC_UNRESTRICTED_GUEST  0x0080
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index d89b0a0..3a880ac 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2916,6 +2916,11 @@ static bool svm_gb_page_enable(void)
return true;
 }
 
+static bool svm_rdtscp_supported(void)
+{
+   return false;
+}
+
 static struct kvm_x86_ops svm_x86_ops = {
.cpu_has_kvm_support = has_svm,
.disabled_by_bios = is_disabled,
@@ -2984,6 +2989,8 @@ static struct kvm_x86_ops svm_x86_ops = {
.gb_page_enable = svm_gb_page_enable,
 
.cpuid_update = svm_cpuid_update,
+
+   .rdtscp_supported = svm_rdtscp_supported,
 };
 
 static int __init svm_init(void)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 91dff23..584403f 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -136,6 +136,8 @@ struct vcpu_vmx {
ktime_t entry_time;
s64 vnmi_blocked_time;
u32 exit_reason;
+
+   bool rdtscp_enabled;
 };
 
 static inline struct vcpu_vmx *to_vmx(struct kvm_vcpu *vcpu)
@@ -210,7 +212,7 @@ static const u32 vmx_msr_index[] = {
 #ifdef CONFIG_X86_64
MSR_SYSCALL_MASK, MSR_LSTAR, MSR_CSTAR,
 #endif
-   MSR_EFER, MSR_K6_STAR,
+   MSR_EFER, MSR_TSC_AUX, MSR_K6_STAR,
 };
 #define NR_VMX_MSR ARRAY_SIZE(vmx_msr_index)
 
@@ -347,6 +349,12 @@ static inline int cpu_has_vmx_vpid(void)
SECONDARY_EXEC_ENABLE_VPID;
 }
 
+static inline int cpu_has_vmx_rdtscp(void)
+{
+   return vmcs_config.cpu_based_2nd_exec_ctrl 
+   SECONDARY_EXEC_RDTSCP;
+}
+
 static inline int cpu_has_virtual_nmis(void)
 {
return vmcs_config.pin_based_exec_ctrl  PIN_BASED_VIRTUAL_NMIS;
@@ -878,6 +886,11 @@ static void vmx_queue_exception(struct kvm_vcpu *vcpu, 
unsigned nr,
vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, intr_info);
 }
 
+static bool vmx_rdtscp_supported(void)
+{
+   return cpu_has_vmx_rdtscp();
+}
+
 /*
  * Swap MSR entry in host/guest MSR entry array.
  */
@@ -913,6 +926,9 @@ static void setup_msrs(struct vcpu_vmx *vmx)
index = __find_msr_index(vmx, MSR_CSTAR);
if (index = 0)
move_msr_up(vmx, index, save_nmsrs++);
+   index = __find_msr_index(vmx, MSR_TSC_AUX);
+   if (index = 0  vmx-rdtscp_enabled)
+   move_msr_up(vmx, index, save_nmsrs++);
/*
 * MSR_K6_STAR is only needed on long mode guests, and only
 * if efer.sce is enabled.
@@ -1002,6 +1018,10 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, u32 
msr_index, u64 *pdata)
case MSR_IA32_SYSENTER_ESP:
data = vmcs_readl(GUEST_SYSENTER_ESP);
break;
+   case MSR_TSC_AUX:
+   if (!to_vmx(vcpu)-rdtscp_enabled)
+   return 1;
+   /* Otherwise falls through */
default:
vmx_load_host_state(to_vmx(vcpu));
msr = find_msr_entry(to_vmx(vcpu), msr_index);
@@ -1065,7 +1085,15 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 
msr_index, u64 data)
vcpu-arch.pat = data;
break;
}
-   /* Otherwise falls through to kvm_set_msr_common */
+   ret = kvm_set_msr_common(vcpu, msr_index, data);
+   break;
+   case MSR_TSC_AUX:
+   if (!vmx-rdtscp_enabled)
+   return 1;
+   /* Check reserved bit, higher 32 bits should be zero */
+   if ((data  32) != 0)
+  

Re: SIGTERM to qemu-kvm process destroys qcow2 image?

2009-12-18 Thread Kenni Lund
2009/12/17 Kevin Wolf kw...@redhat.com:
 Am 17.12.2009 11:23, schrieb Avi Kivity:
 On 12/17/2009 11:38 AM, Kenni Lund wrote:
 2009/12/17 Avi Kivitya...@redhat.com:

 On 12/17/2009 02:52 AM, Kenni Lund wrote:

 Yesterday I entered an invalid boot device as an argument to my
 qemu-kvm command for my Windows XP machine, causing an error about a
 missing boot device in the qemu BIOS/POST. As I didn't have any
 filesystems mounted inside the virtual machine (since it was stuck at
 the BIOS asking for a device to boot), I did a kill $pid, fixed the
 boot device in the qemu-kvm command and tried booting again...but with
 no luck, whatever I try now with qemu-kvm gives me the error:
 qemu: could not open disk image /data/virtualization/WindowsXP.img

 And qemu-img (check, convert, etc) gives me:
 qemu-img: Could not open 'WindowsXP.img'


 Can you post the first 4K of the image?  It shouldn't contain private data,
 but go over it (or don't post) if you sensitive information there.

 4K dump attached.



 Seems fine.  Kevin can you take a look?

 Agreed, the dump looks fine. Even qcow2_open succeeds if I just use this
 header as a qcow2 file.

 You have a backing file.  Do qemu-img info and qemu-img check like it?

 So I'd definitely have a look at the backing file. It's almost the only
 thing that can go wrong after qcow2_open. qemu-img doesn't have known
 problems with backing files in general, but it does have problems with
 missing (or broken) backing files.

 Kenni, could you check if your backing file is still alive? /tmp doesn't
 sound like a safe place for images. If it still exists in the right
 location (/tmp/WindowsXP.img.backup) and it is qcow2, can you please
 attach the first 4k of the backing file?

 Kevin


Huh? Backing file? Is that the same as a base image? Eg. a write
protected image on which other images can be based?

If so, I'm quite confused...this should be a standalone image created
with a command like qemu-img create -f WindowsXP.img 50G half a year
ago on kvm 8x. I don't use libvirt/virt-manager etc. I start qemu-kvm
directly from a homemade bash script. I don't have any
/tmp/WindowsXP.img.backup file, and I would never put stuff inside
/tmp, especially not images, they belong to /data/virtualization/ on
my server and nowhere else

If the image needs another image in /tmp/WindowsXP.img.backup I can
see why it doesn't work, but I have _no_ idea why or how this file was
created (?!??) - even if I was doing a test with base-images, I would
do it directly in /data/virtualization/ and never in /tmp/

Best Regards
Kenni Lund
--
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: SIGTERM to qemu-kvm process destroys qcow2 image?

2009-12-18 Thread Avi Kivity

On 12/18/2009 04:13 PM, Kenni Lund wrote:


Huh? Backing file? Is that the same as a base image? Eg. a write
protected image on which other images can be based?

   


Yes.


If so, I'm quite confused...this should be a standalone image created
with a command like qemu-img create -f WindowsXP.img 50G half a year
ago on kvm 8x. I don't use libvirt/virt-manager etc. I start qemu-kvm
directly from a homemade bash script. I don't have any
/tmp/WindowsXP.img.backup file, and I would never put stuff inside
/tmp, especially not images, they belong to /data/virtualization/ on
my server and nowhere else
   


The '/tmp' was prefixed by qemu-img, the actual path is 
'WindowsXP.img.backup', so on your setup qemu-img would look for it in 
/data/virtualization/.



If the image needs another image in /tmp/WindowsXP.img.backup I can
see why it doesn't work, but I have _no_ idea why or how this file was
created (?!??) - even if I was doing a test with base-images, I would
do it directly in /data/virtualization/ and never in /tmp/
   


If it isn't there you can try to create it (qemu-img create 
/data/virtualization/WindowsXP.img.backup 3145728).  If no data was 
actually stored there, your image will be recovered.



--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

--
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: SIGTERM to qemu-kvm process destroys qcow2 image?

2009-12-18 Thread Kevin Wolf
Am 18.12.2009 15:22, schrieb Avi Kivity:
 If so, I'm quite confused...this should be a standalone image created
 with a command like qemu-img create -f WindowsXP.img 50G half a year
 ago on kvm 8x. I don't use libvirt/virt-manager etc. I start qemu-kvm
 directly from a homemade bash script. I don't have any
 /tmp/WindowsXP.img.backup file, and I would never put stuff inside
 /tmp, especially not images, they belong to /data/virtualization/ on
 my server and nowhere else

 
 The '/tmp' was prefixed by qemu-img, the actual path is 
 'WindowsXP.img.backup', so on your setup qemu-img would look for it in 
 /data/virtualization/.

Whoops, I've been tricked by qemu-img. Sorry. I thought I had seen this
path in hexdump, but obviously that was wrong.

Kevin
--
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: SIGTERM to qemu-kvm process destroys qcow2 image?

2009-12-18 Thread Kenni Lund
2009/12/18 Avi Kivity a...@redhat.com:
 On 12/18/2009 04:13 PM, Kenni Lund wrote:
 The '/tmp' was prefixed by qemu-img, the actual path is
 'WindowsXP.img.backup', so on your setup qemu-img would look for it in
 /data/virtualization/.

 If the image needs another image in /tmp/WindowsXP.img.backup I can
 see why it doesn't work, but I have _no_ idea why or how this file was
 created (?!??) - even if I was doing a test with base-images, I would
 do it directly in /data/virtualization/ and never in /tmp/


 If it isn't there you can try to create it (qemu-img create
 /data/virtualization/WindowsXP.img.backup 3145728).  If no data was
 actually stored there, your image will be recovered.

Thanks, this explains the whole thing - this is own mistake, I move
all the backups into a subdirectory, I didn't know that I had based
the image on a backup-image, bad design decision on my part.

I'm sorry for the false alarm, thanks a lot for your help :)

Best Regards
Kenni Lund
--
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: [Autotest] [KVM-AUTOTEST] KSM-overcommit test v.2 (python version)

2009-12-18 Thread Lukáš Doktor

Hello ppl,

as we promised there is a new version with modifications you wanted us 
to do. It's complete package based on the newest GIT version.


[Changelog]
- new structure (tests_base.cfg, ...)
- improved log
- function get_stat() raise an error when access death VM
- get_stat() splitted into 2 functions, _get_stat() returns int, 
get_stat returns log string

- use of session.close() instead of get_command_status('exit;')
- PID of VM is taken using -pidfile option (RFC: It would be nice to 
have this in framework by default)

- possible infinite loop (i = i + 1)
- 32bit host supports 3.1GB guest, 64bit without limitation, detection 
using image file_name


[Not changed]
- We skip the merge of serial and parallel init functions as the result 
would be way more complicated (= more possible errors)
From 3420916facae18f45617e3c25c365eaa59c0374c Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Luk=C3=A1=C5=A1=20Doktor?= me...@book.localdomain
Date: Fri, 18 Dec 2009 15:56:31 +0100
Subject: [KSM-autotest] KSM overcommit v2 modification
[Changelog]
 - new structure (tests_base.cfg, ...)
 - improved log
 - function get_stat() raise an error when access death VM
 - get_stat() splitted into 2 functions, _get_stat() returns int, get_stat returns log string
 - PID of VM is taken using -pidfile option (RFC: It would be nice to have this in framework by default)
 - possible infinite loop (i = i + 1)
 - 32bit host supports 3.1GB guest, 64bit without limitation, detection using image file_name

[Not changed]
- We skip the merge of serial and parallel init functions as the result would be way more complicated (= more possible errors)
---
 client/tests/kvm/tests/ksm_overcommit.py |  616 ++
 client/tests/kvm/tests_base.cfg.sample   |   18 +
 client/tests/kvm/unattended/allocator.py |  213 ++
 3 files changed, 847 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/ksm_overcommit.py
 create mode 100644 client/tests/kvm/unattended/allocator.py

diff --git a/client/tests/kvm/tests/ksm_overcommit.py b/client/tests/kvm/tests/ksm_overcommit.py
new file mode 100644
index 000..a726e1c
--- /dev/null
+++ b/client/tests/kvm/tests/ksm_overcommit.py
@@ -0,0 +1,616 @@
+import logging, time
+from autotest_lib.client.common_lib import error
+import kvm_subprocess, kvm_test_utils, kvm_utils
+import kvm_preprocessing
+import random, string, math, os
+
+def run_ksm_overcommit(test, params, env):
+
+Test how KSM (Kernel Shared Memory) act with more than physical memory is
+used. In second part is also tested, how KVM can handle the situation,
+when the host runs out of memory (expected is to pause the guest system,
+wait until some process returns the memory and bring the guest back to life)
+
+@param test: kvm test object.
+@param params: Dictionary with test parameters.
+@param env: Dictionary with the test wnvironment.
+
+
+def parse_meminfo(rowName):
+
+Function get date from file /proc/meminfo
+
+@param rowName: Name of line in meminfo 
+
+for line in open('/proc/meminfo').readlines():
+if line.startswith(rowName+:):
+name, amt, unit = line.split()
+return name, amt, unit   
+
+def parse_meminfo_value(rowName):
+
+Function convert meminfo value to int
+
+@param rowName: Name of line in meminfo  
+
+name, amt, unit = parse_meminfo(rowName)
+return amt
+
+def _get_stat(vm):
+if vm.is_dead():
+error.TestError(_get_stat: Trying to get informations of death\
+VM: %s % vm.name)
+try:
+cmd = cat /proc/%d/statm % params.get('pid_'+vm.name)
+shm = int(os.popen(cmd).readline().split()[2])
+# statm stores informations in pages, recalculate to MB
+shm = shm * 4 / 1024
+except:
+raise error.TestError(_get_stat: Could not fetch shmem info from\
+  VM: %s % vm.name)
+return shm
+
+def get_stat(lvms):
+
+Get statistics in format:
+Host: memfree = XXXM; Guests memsh = {XXX,XXX,...}
+
+@params lvms: List of VMs
+
+if not isinstance(lvms, list):
+raise error.TestError(get_stat: parameter have to be proper list)
+
+try:
+stat = Host: memfree = 
+stat += str(int(parse_meminfo_value(MemFree)) / 1024) + M; 
+stat += swapfree = 
+stat += str(int(parse_meminfo_value(SwapFree)) / 1024) + M; 
+except:
+raise error.TestFail(Could not fetch free memory info)
+
+
+stat += Guests memsh = {
+for vm in lvms:
+stat += %dM;  % (_get_stat(vm))
+stat = stat[0:-2] + }
+return stat
+
+def tmp_file(file, ext=None, dir='/tmp/'):
+while True:
+

Re: [Autotest] [Autotest PATCH] KVM test: Add a subtest vnc via which interacts with guest

2009-12-18 Thread Ryan Harper
* Yolkfull Chow yz...@redhat.com [2009-12-17 22:51]:
 Signed-off-by: Yolkfull Chow yz...@redhat.com
 ---
  client/tests/kvm/tests/vnc.py  |   24 
  client/tests/kvm/tests_base.cfg.sample |3 +++
  2 files changed, 27 insertions(+), 0 deletions(-)
  create mode 100644 client/tests/kvm/tests/vnc.py
 
 diff --git a/client/tests/kvm/tests/vnc.py b/client/tests/kvm/tests/vnc.py
 new file mode 100644
 index 000..0f00379
 --- /dev/null
 +++ b/client/tests/kvm/tests/vnc.py
 @@ -0,0 +1,24 @@
 +import logging, pexpect
 +from autotest_lib.client.common_lib import  error
 +import kvm_test_utils, kvm_subprocess
 +
 +def run_vnc(test, params, env):
 +
 +Test whether guest could be interacted with vnc.
 +
 +@param test: kvm test object
 +@param params: Dictionary with the test parameters
 +@param env: Dictionary with test environment.
 +
 +vm = kvm_test_utils.get_living_vm(env, params.get(main_vm))
 +session = kvm_test_utils.wait_for_login(vm)
 +
 +# Start vnc connection test
 +vnc_port = str(vm.vnc_port - 5900)
 +vnc_cmd = vncviewer +  localhost: + vnc_port

Can we make this configurable? vncviewer does have a few bugs that kvm
tends to expose; it'd be good to let the admin set this value.


 +logging.debug(Using command to vnc connect: %s % vnc_cmd)
 +
 +p = kvm_subprocess.run_bg(vnc_cmd, None, logging.debug, (vnc) )
 +if not p.is_alive():
 +raise error.TestFail(Vnc connect to guest failed)
 +p.close()
 diff --git a/client/tests/kvm/tests_base.cfg.sample 
 b/client/tests/kvm/tests_base.cfg.sample
 index a403399..0eaccae 100644
 --- a/client/tests/kvm/tests_base.cfg.sample
 +++ b/client/tests/kvm/tests_base.cfg.sample
 @@ -270,6 +270,9 @@ variants:
  type = physical_resources_check
  catch_uuid_cmd = dmidecode | awk -F: '/UUID/ {print $2}'
 
 +- vnc: install setup unattended_install
 +type = vnc
 +
  # NICs
  variants:
  - @rtl8139:
 -- 
 1.6.5.5
 
 ___
 Autotest mailing list
 autot...@test.kernel.org
 http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ry...@us.ibm.com
--
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: [GIT PULL] AlacrityVM guest drivers for 2.6.33

2009-12-18 Thread Ingo Molnar

* Gregory Haskins gregory.hask...@gmail.com wrote:

 Hi Linus,
 
 Please pull AlacrityVM guest support for 2.6.33 from:
 
 git://git.kernel.org/pub/scm/linux/kernel/git/ghaskins/alacrityvm/linux-2.6.git
 for-linus
 
 All of these patches have stewed in linux-next for quite a while now:
 
 Gregory Haskins (26):

I think it would be fair to point out that these patches have been objected to 
by the KVM folks quite extensively, on multiple technical grounds - as 
basically this tree forks the KVM driver space for which no valid technical 
reason could be offered by you in a 100+ mails long discussion.

(And yes, i've been Cc:-ed to much of that thread.)

The result will IMO be pain for users because now we'll have two frameworks, 
tooling incompatibilities, etc. etc.

I've extended the Cc: for the KVM folks to have a chance to reply. Please try 
_much_ harder to work with the KVM folks instead of ignoring their feedback 
and de-facto forking their project. (and not mentioning any of this in your 
pull request) We should unify, not fracture.

Ingo
--
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


buildbot failure in qemu-kvm on default_x86_64_debian_5_0

2009-12-18 Thread qemu-kvm
The Buildbot has detected a new failure of default_x86_64_debian_5_0 on 
qemu-kvm.
Full details are available at:
 
http://buildbot.b1-systems.de/qemu-kvm/builders/default_x86_64_debian_5_0/builds/208

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

Buildslave for this Build: b1_qemu_kvm_1

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

BUILD FAILED: failed compile

sincerely,
 -The Buildbot

--
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


buildbot failure in qemu-kvm on default_i386_debian_5_0

2009-12-18 Thread qemu-kvm
The Buildbot has detected a new failure of default_i386_debian_5_0 on qemu-kvm.
Full details are available at:
 
http://buildbot.b1-systems.de/qemu-kvm/builders/default_i386_debian_5_0/builds/210

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

Buildslave for this Build: b1_qemu_kvm_2

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

BUILD FAILED: failed compile

sincerely,
 -The Buildbot

--
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


buildbot failure in qemu-kvm on default_x86_64_out_of_tree

2009-12-18 Thread qemu-kvm
The Buildbot has detected a new failure of default_x86_64_out_of_tree on 
qemu-kvm.
Full details are available at:
 
http://buildbot.b1-systems.de/qemu-kvm/builders/default_x86_64_out_of_tree/builds/149

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

Buildslave for this Build: b1_qemu_kvm_1

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

BUILD FAILED: failed compile

sincerely,
 -The Buildbot

--
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


buildbot failure in qemu-kvm on default_i386_out_of_tree

2009-12-18 Thread qemu-kvm
The Buildbot has detected a new failure of default_i386_out_of_tree on qemu-kvm.
Full details are available at:
 
http://buildbot.b1-systems.de/qemu-kvm/builders/default_i386_out_of_tree/builds/147

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

Buildslave for this Build: b1_qemu_kvm_2

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

BUILD FAILED: failed compile

sincerely,
 -The Buildbot

--
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