Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix live migration #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions qemu-kvm-x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include <sys/kvm_para.h>
#endif
#include <sys/ioctl.h>
#ifdef __sun
#include <sys/systeminfo.h>
#endif

#include "kvm.h"
#include "hw/apic.h"
Expand Down Expand Up @@ -506,9 +509,19 @@ int kvm_arch_qemu_create_context(void)
{
int r;
struct utsname utsname;
char sysinfo_arch[20];

uname(&utsname);
lm_capable_kernel = strcmp(utsname.machine, "x86_64") == 0;
if(strcmp(utsname.sysname, "SunOS") == 0) {
sysinfo(SI_ARCHITECTURE_K, sysinfo_arch, sizeof(sysinfo_arch));
if(strcmp(sysinfo_arch, "amd64") == 0) {
lm_capable_kernel = 1;
} else {
lm_capable_kernel = 0;
}
}
else
lm_capable_kernel = strcmp(utsname.machine, "x86_64") == 0;

if (kvm_shadow_memory) {
kvm_set_shadow_pages(kvm_context, kvm_shadow_memory);
Expand Down Expand Up @@ -723,11 +736,12 @@ void kvm_arch_push_nmi(void *opaque)
static int kvm_reset_msrs(CPUState *env)
{
struct {
struct kvm_msrs info;
uint32_t nmsrs; /* number of msrs in entries */
uint32_t pad;
struct kvm_msr_entry entries[100];
} msr_data;
} kvm_msrs;
int n;
struct kvm_msr_entry *msrs = msr_data.entries;
struct kvm_msr_entry *msrs = kvm_msrs.entries;
uint32_t index;
uint64_t data;

Expand All @@ -747,9 +761,9 @@ static int kvm_reset_msrs(CPUState *env)
kvm_msr_entry_set(&msrs[n], kvm_msr_list->indices[n], data);
}

msr_data.info.nmsrs = n;
kvm_msrs.nmsrs = n;

return kvm_vcpu_ioctl(env, KVM_SET_MSRS, &msr_data);
return kvm_vcpu_ioctl(env, KVM_SET_MSRS, &kvm_msrs);
}


Expand Down
22 changes: 12 additions & 10 deletions target-i386/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,11 @@ static void kvm_msr_entry_set(struct kvm_msr_entry *entry,
static int kvm_put_msrs(CPUState *env, int level)
{
struct {
struct kvm_msrs info;
uint32_t nmsrs; /* number of msrs in entries */
uint32_t pad;
struct kvm_msr_entry entries[100];
} msr_data;
struct kvm_msr_entry *msrs = msr_data.entries;
} kvm_msrs;
struct kvm_msr_entry *msrs = kvm_msrs.entries;
int n = 0;

kvm_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_CS, env->sysenter_cs);
Expand Down Expand Up @@ -903,9 +904,9 @@ static int kvm_put_msrs(CPUState *env, int level)
}
#endif

msr_data.info.nmsrs = n;
kvm_msrs.nmsrs = n;

return kvm_vcpu_ioctl(env, KVM_SET_MSRS, &msr_data);
return kvm_vcpu_ioctl(env, KVM_SET_MSRS, &kvm_msrs);

}

Expand Down Expand Up @@ -1091,10 +1092,11 @@ static int kvm_get_sregs(CPUState *env)
static int kvm_get_msrs(CPUState *env)
{
struct {
struct kvm_msrs info;
uint32_t nmsrs; /* number of msrs in entries */
uint32_t pad;
struct kvm_msr_entry entries[100];
} msr_data;
struct kvm_msr_entry *msrs = msr_data.entries;
} kvm_msrs;
struct kvm_msr_entry *msrs = kvm_msrs.entries;
int ret, i, n;

n = 0;
Expand Down Expand Up @@ -1134,8 +1136,8 @@ static int kvm_get_msrs(CPUState *env)
}
#endif

msr_data.info.nmsrs = n;
ret = kvm_vcpu_ioctl(env, KVM_GET_MSRS, &msr_data);
kvm_msrs.nmsrs = n;
ret = kvm_vcpu_ioctl(env, KVM_GET_MSRS, &kvm_msrs);
if (ret < 0) {
return ret;
}
Expand Down