Skip to content

Commit

Permalink
kvm_set_msrs() is now on available
Browse files Browse the repository at this point in the history
  • Loading branch information
ddk committed Sep 22, 2010
1 parent 36ebcff commit a120b1d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 25 deletions.
24 changes: 11 additions & 13 deletions kvm/winkvm-qemu/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -954,14 +954,12 @@ static int migrate_incoming_tcp(const char *host)

wait_for_go:
// len = read(sfd, &status, 1);
len = recv(sfd, &status, 1, 0);
len = recv(sfd, &status, 1, 0);
if (len == -1 && errno == EAGAIN)
goto wait_for_go;
goto wait_for_go;
if (len != 1)
rc = MIG_STAT_DST_READ_FAILED;

fprintf(stderr, "migrate incoming tcp end\n");

error_accept:
close(sfd);
error_socket:
Expand All @@ -976,17 +974,17 @@ int migrate_incoming(const char *device)
int ret = 0;

if (strcmp(device, "stdio") == 0)
ret = migrate_incoming_fd(STDIN_FILENO);
ret = migrate_incoming_fd(STDIN_FILENO);
else if (strstart(device, "tcp://", &ptr)) {
char *host, *end;
host = strdup(ptr);
end = strchr(host, '/');
if (end) *end = 0;
ret = migrate_incoming_tcp(host);
qemu_free(host);
char *host, *end;
host = strdup(ptr);
end = strchr(host, '/');
if (end) *end = 0;
ret = migrate_incoming_tcp(host);
qemu_free(host);
} else {
errno = EINVAL;
ret = MIG_STAT_DST_INVALID_PARAMS;
errno = EINVAL;
ret = MIG_STAT_DST_INVALID_PARAMS;
}

return ret;
Expand Down
3 changes: 3 additions & 0 deletions vcproj/include/linux/kvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ struct kvm_msr_entry {

/* for KVM_GET_MSRS and KVM_SET_MSRS */
struct kvm_msrs {
#ifdef __WINKVM__
int vcpu_fd;
#endif
__u32 nmsrs; /* number of msrs in entries */
__u32 pad;

Expand Down
40 changes: 28 additions & 12 deletions vcproj/user/kvmctldll/kvmctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,26 +1160,42 @@ int __cdecl kvm_get_msrs(kvm_context_t kvm, int vcpu, struct kvm_msr_entry *msrs

int __cdecl kvm_set_msrs(kvm_context_t kvm, int vcpu, struct kvm_msr_entry *msrs, int n)
{
// fprintf(stderr, " %s implement me\n", __FUNCTION__);
/*
struct kvm_msrs *kmsrs = malloc(sizeof *kmsrs + n * sizeof *msrs);
int r, e;
unsigned long retlen;
struct kvm_msrs *kmsrs;
unsigned long total_size = sizeof(*kmsrs) + n * sizeof(*msrs);
// int r, e;
BOOL ret;

kmsrs = (struct kvm_msrs*)malloc(total_size);
if (!kmsrs) {
// errno = ENOMEM;
errno = ENOMEM;
return -1;
}

kmsrs->nmsrs = n;
memcpy(kmsrs->entries, msrs, n * sizeof *msrs);
// r = ioctl(kvm->vcpu_fd[vcpu], KVM_SET_MSRS, kmsrs);
e = errno;
kmsrs->vcpu_fd = kvm->vcpu_fd[vcpu];

memcpy(kmsrs->entries, msrs, n * sizeof(*msrs));

ret = DeviceIoControl(
kvm->hnd,
KVM_SET_MSRS,
kmsrs,
total_size,
NULL,
0,
&retlen,
NULL);

// r = ioctl(kvm->vcpu_fd[vcpu], KVM_SET_MSRS, kmsrs);
// e = errno;
free(kmsrs);
errno = e;
return r;
*/
return -1;
// errno = e;

if (ret)
return 1;
else
return -1;
}


Expand Down

0 comments on commit a120b1d

Please sign in to comment.