qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] qemu / KVM modification to yield to external component (how


From: Lloret, Luis
Subject: [Qemu-devel] qemu / KVM modification to yield to external component (how to make it ignore the time the external component is running)
Date: Wed, 13 Feb 2013 11:10:14 +0000

Hi, qemu experts,

We are using qemu with KVM for some experiments that involve qemu yielding to 
an external process periodically. By yielding, what I mean is that qemu will 
stop executing for some time while the external process does its job and 
reports back to qemu. The external process is a remote HW model. The handshake 
happens with normal TCP sockets, and the platform that this is running on has 
the constraint that qemu and the external model cannot execute concurrently. So 
they need to work in a kind of ping-pong mode. That is why we need this 
synchronization mechanism. 

The yield is done inside a normal qemu timer callback. And this is the relevant 
code for what I am talking about.
// Install the timer
sim_sync_timer = qemu_new_timer_ns (vm_clock, sim_sync_callback, NULL);

-----

// This is the callback definition. It just calls the sync function and 
reprograms the periodic timer
static void sim_sync_callback (void *p){
  qemutbx_send_sync (qemu_get_clock_ns (vm_clock));
  qemu_mod_timer (sim_sync_timer, qemu_get_clock_ns (vm_clock) + 
syncTimerExpiredTime );
}

------

// This is the function where we yield to the external program 
int qemu_send_sync (unsigned long long vmtime)
{
    struct qemu_message msg;
    memset(&msg,0,sizeof(struct qemutbx_message));
    //vm_stop_sync();
    msg.mtype   = QEMU_MESSAGE_SYNC;
    msg.mAck    = QEMU_MESSAGE_SYNC_DONE;
    msg.vm_time = vmtime;

// send the sync message to the external program. We will wait here until the 
external program replies back
    qemu_send_msg_and_wait_ack(&msg); // This is just blocking TCP send and 
receive
    //vm_start();
    return 0;
}


What we want is that this time where the external process is executing and qemu 
is waiting, was completely transparent to the software, drivers, etc, running 
inside qemu. And we do not care if clocks and time inside qemu deviate from 
real wall clock time. What we want is that this external execution time is not 
seen by qemu and the guest in general. So, for example if qemu runs for 2 
seconds of virtual time, then yields to the external process that takes 3 
seconds to process, what we expect is that when qemu resumes it does at virtual 
time 2, without trying to synchronize at all with the real time on the host. 
Like if the 3 seconds of real time hadn't existed.

So far, I have been trying with linux clocksources (to change from the default 
kvm-clock), vm_stop and vm_start (so that the yield to external happens inside 
a vm_stop / vm_start block), but nothing seems to work as I expect.

For example, some driver code seems to time out, because it is probably seeing 
the time that this external process is running (and qemu isn't) as time that 
has elapsed from its point of view. 

Perhaps this would be easier without KVM (I don't know), but KVM is a must 
too... 

Can someone give some pointers as to what we should do to achieve this? Any 
idea would be greatly appreciated.

Thanks in advance,
Luis



reply via email to

[Prev in Thread] Current Thread [Next in Thread]