diff --git a/sys/amd64/include/vmm_snapshot.h b/sys/amd64/include/vmm_snapshot.h --- a/sys/amd64/include/vmm_snapshot.h +++ b/sys/amd64/include/vmm_snapshot.h @@ -113,6 +113,7 @@ #define SNAPSHOT_VAR_OR_LEAVE(DATA, META, RES, LABEL) \ SNAPSHOT_BUF_OR_LEAVE(&(DATA), sizeof(DATA), (META), (RES), LABEL) +#ifndef _KERNEL /* compare the value in the meta buffer with the data */ #define SNAPSHOT_BUF_CMP_OR_LEAVE(DATA, LEN, META, RES, LABEL) \ do { \ @@ -126,4 +127,5 @@ #define SNAPSHOT_VAR_CMP_OR_LEAVE(DATA, META, RES, LABEL) \ SNAPSHOT_BUF_CMP_OR_LEAVE(&(DATA), sizeof(DATA), (META), (RES), LABEL) +#endif /* _KERNEL */ #endif diff --git a/sys/amd64/vmm/vmm_snapshot.c b/sys/amd64/vmm/vmm_snapshot.c --- a/sys/amd64/vmm/vmm_snapshot.c +++ b/sys/amd64/vmm/vmm_snapshot.c @@ -57,7 +57,7 @@ vm_snapshot_buf(void *data, size_t data_size, struct vm_snapshot_meta *meta) { struct vm_snapshot_buffer *buffer; - int op; + int op, error; buffer = &meta->buffer; op = meta->op; @@ -68,11 +68,14 @@ } if (op == VM_SNAPSHOT_SAVE) - copyout(data, buffer->buf, data_size); + error = copyout(data, buffer->buf, data_size); else if (op == VM_SNAPSHOT_RESTORE) - copyin(buffer->buf, data, data_size); + error = copyin(buffer->buf, data, data_size); else - return (EINVAL); + error = EINVAL; + + if (error) + return (error); buffer->buf += data_size; buffer->buf_rem -= data_size; @@ -98,36 +101,3 @@ return (length); } - -int -vm_snapshot_buf_cmp(void *data, size_t data_size, struct vm_snapshot_meta *meta) -{ - struct vm_snapshot_buffer *buffer; - int op; - int ret; - - buffer = &meta->buffer; - op = meta->op; - - if (buffer->buf_rem < data_size) { - printf("%s: buffer too small\r\n", __func__); - ret = E2BIG; - goto done; - } - - if (op == VM_SNAPSHOT_SAVE) { - ret = 0; - copyout(data, buffer->buf, data_size); - } else if (op == VM_SNAPSHOT_RESTORE) { - ret = memcmp(data, buffer->buf, data_size); - } else { - ret = EINVAL; - goto done; - } - - buffer->buf += data_size; - buffer->buf_rem -= data_size; - -done: - return (ret); -}