On Wed, Nov 24, 2010 at 12:52:13PM +0200, Avi Kivity wrote:
> Call a function setting a global variable.
> 
> Signed-off-by: Avi Kivity <a...@redhat.com>
> ---
>  config-x86-common.mak |    8 +++++++-
>  x86/api-sample.cc     |   23 +++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 1 deletions(-)
>  create mode 100644 x86/api-sample.cc
> 
> diff --git a/config-x86-common.mak b/config-x86-common.mak
> index 0f3387b..4fef070 100644
> --- a/config-x86-common.mak
> +++ b/config-x86-common.mak
> @@ -29,6 +29,8 @@ tests-common = $(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat 
> \
>                 $(TEST_DIR)/hypercall.flat $(TEST_DIR)/sieve.flat \
>                 $(TEST_DIR)/kvmclock_test.flat
>  
> +tests-common += $(TEST_DIR)/api-sample
> +
>  tests_and_config = $(TEST_DIR)/*.flat $(TEST_DIR)/unittests.cfg
>  
>  test_cases: $(tests-common) $(tests)
> @@ -80,4 +82,8 @@ arch_clean:
>  
>  -include $(TEST_DIR)/.*.d lib/.*.d lib/x86/.*.d
>  
> -api/%.o: CFLAGS += -m32
> \ No newline at end of file
> +api/%.o x86/api-sample.o x86/api-sample: CFLAGS += -m32
> +
> +x86/api-sample: LDLIBS += -lstdc++
> +
> +x86/api-sample: x86/api-sample.o api/kvmxx.o api/identity.o
> \ No newline at end of file
> diff --git a/x86/api-sample.cc b/x86/api-sample.cc
> new file mode 100644
> index 0000000..a603328
> --- /dev/null
> +++ b/x86/api-sample.cc
> @@ -0,0 +1,23 @@
> +
> +#include "api/kvmxx.h"
> +#include "api/identity.h"
> +#include "stdio.h"
> +
> +static int global = 0;
> +
> +static void set_global()
> +{
> +    global = 1;
> +}
> +
> +int main(int ac, char **av)
> +{
> +    kvm::system system;
> +    kvm::vm vm(system);
> +    identity::setup_vm(vm);
> +    kvm::vcpu vcpu(vm, 0);
> +    identity::vcpu thread(vcpu, set_global);
> +    vcpu.run();
> +    printf("global %d\n", global);
> +    return global == 1;
> +}

I note that no exceptions are caught.  So any failure will get us a crash,
is there an indication what went wrong?

> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to