Page MenuHomeFreeBSD

vmm: Fix compiling error with BHYVE_SNAPSHOT
ClosedPublic

Authored by gusev.vitaliy_gmail.com on Feb 5 2024, 10:34 PM.
Tags
Referenced Files
Unknown Object (File)
Wed, Jun 19, 6:22 AM
Unknown Object (File)
Wed, Jun 19, 6:22 AM
Unknown Object (File)
Wed, Jun 19, 6:22 AM
Unknown Object (File)
May 19 2024, 12:04 PM
Unknown Object (File)
May 4 2024, 2:05 AM
Unknown Object (File)
Apr 27 2024, 8:48 AM
Unknown Object (File)
Apr 27 2024, 7:52 AM
Unknown Object (File)
Apr 27 2024, 7:52 AM

Details

Summary

error: ignoring return value of function declared with 'warn_unused_result'

sys/amd64/vmm/vmm_snapshot.c:73:3: error: ignoring return value of function
declared with 'warn_unused_result' attribute [-Werror,-Wunused-result]

copyin(buffer->buf, data, data_size);

Sponsored by: vStack

Test Plan

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/amd64/vmm/vmm_snapshot.c
103

memcmp() doesn't return an error value. The code should do something like:

error = memcmp(...) != 0 ? EINVAL : 0;

Also, shouldn't there be a copyin()?

This function is rather strange - does it get used anywhere? I can't find any callers.

Removed vm_snapshot_buf_cmp() function in the kernel code.

sys/amd64/vmm/vmm_snapshot.c
103

Yes, you are right, it is only used in userspace via SNAPSHOT_VAR_CMP_OR_LEAVE() in usr.sbin/bhyve/virtio.c :

vi_pci_snapshot_consts[867]    SNAPSHOT_VAR_CMP_OR_LEAVE(vc->vc_nvq, meta, ret, done);
vi_pci_snapshot_consts[868]    SNAPSHOT_VAR_CMP_OR_LEAVE(vc->vc_cfgsize, meta, ret, done);
vi_pci_snapshot_consts[869]    SNAPSHOT_VAR_CMP_OR_LEAVE(vc->vc_hv_caps, meta, ret, done);
vi_pci_snapshot_queues[892]    SNAPSHOT_VAR_CMP_OR_LEAVE(vq->vq_qsize, meta, ret, done);
vi_pci_snapshot_queues[893]    SNAPSHOT_VAR_CMP_OR_LEAVE(vq->vq_num, meta, ret, done);

And current usage memcmp() in kernel with userspace buffer is not safe. So I removed this function for the kernel code.

removed vm_snapshot_buf_cmp() in the kernel code

gusev.vitaliy_gmail.com retitled this revision from vmm: Fix compilation with BHYVE_SNAPSHOT to vmm: Fix compiling error with BHYVE_SNAPSHOT.Feb 6 2024, 12:10 PM

Looks good to me, aside from the comment.

sys/amd64/include/vmm_snapshot.h
100–101

The function prototype should also be guarded by #ifndef _KERNEL.

Move vm_snapshot_buf_cmp prototype under #ifndef _KERNEL.

This revision is now accepted and ready to land.Feb 6 2024, 3:14 PM
This revision was automatically updated to reflect the committed changes.