Solution for qemu-kvm-0.13.0 with undefined reference to `kvm_handle_internal_error`

Problem
With the latest version of qemu-kvm, I can't successfully compile with error below:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#make && make install
kvm-all.o: In function `kvm_run':
/home/liheyuan/code/qemu-kvm-0.13.0/qemu-kvm.c:675: undefined reference to `kvm_handle_internal_error'
collect2: ld returned 1 exit status
#make && make install kvm-all.o: In function `kvm_run': /home/liheyuan/code/qemu-kvm-0.13.0/qemu-kvm.c:675: undefined reference to `kvm_handle_internal_error' collect2: ld returned 1 exit status
#make && make install
kvm-all.o: In function `kvm_run':
/home/liheyuan/code/qemu-kvm-0.13.0/qemu-kvm.c:675: undefined reference to `kvm_handle_internal_error'
collect2: ld returned 1 exit status

Cause

The problem was an bug of version 0.13.0.
The developer using an new 'macro definition':KVM_CAP_INTERNAL_ERROR_DATA, but fail to add it to all the places.
As shown below,

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#ifdef KVM_CAP_INTERNAL_ERROR_DATA
xxxxx
#endif
#ifdef KVM_CAP_INTERNAL_ERROR_DATA xxxxx #endif
#ifdef KVM_CAP_INTERNAL_ERROR_DATA
xxxxx
#endif

This article was firsy posted at:Solution for qemu-kvm-0.13.0 with undefined reference to `kvm_handle_internal_error`,don't remove the link if you repost.

Solution
modify qemu-kvm.c, line:674,add the 'macro definition' before and after the 'case:', as follows

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#line674~~677 should be replace like this:
#ifdef KVM_CAP_INTERNAL_ERROR_DATA
case KVM_EXIT_INTERNAL_ERROR:
kvm_handle_internal_error(env, run);
r = 1;
break;
#endif
#line674~~677 should be replace like this: #ifdef KVM_CAP_INTERNAL_ERROR_DATA case KVM_EXIT_INTERNAL_ERROR: kvm_handle_internal_error(env, run); r = 1; break; #endif
#line674~~677 should be replace like this:
#ifdef KVM_CAP_INTERNAL_ERROR_DATA
case KVM_EXIT_INTERNAL_ERROR:
kvm_handle_internal_error(env, run);
r = 1;
break;
#endif

Recompile with make && make install , all is well.

This article was firsy posted at:Solution for qemu-kvm-0.13.0 with undefined reference to `kvm_handle_internal_error`,don't remove the link if you repost.

Leave a Reply

Your email address will not be published. Required fields are marked *