Fix bugs and clean up code

Tracked-On: #7820
Signed-off-by: Matthew Leon <matthew.leon@intel.com>
This commit is contained in:
Matthew Leon 2022-07-06 11:34:41 -07:00 committed by acrnsi-robot
parent 905b31549e
commit dcb01e1de2
6 changed files with 58 additions and 48 deletions

View File

@ -1,11 +1,11 @@
ACRN Sample Application
#######################
This directory contains the software that is necessary to run a real-time application between a real-time VM and a standard VM using the acrn-hypervisor.
This directory contains a software application that runs a real-time application between a real-time VM and a standard VM using the acrn-hypervisor.
The ``rtvm`` directory contains the code required to pipe data from ``cyclictest`` to the User VM using the inter-vm shared memory feature that acrn-hypervisor exposes to its VMs.
The ``rtvm`` directory contains the code that reads and pipes data from ``cyclictest`` to the User VM using the inter-vm shared memory feature that acrn-hypervisor exposes to its VMs.
The ``uservm`` directory contains the code required to read the piped data from the RTVM, process the data, and display that data over a web application that can be accessed from the hypervisor's Service VM.
The ``uservm`` directory contains the code that reads the piped data from the RTVM, processes the data, and displays the data over a web application that can be accessed from the hypervisor's Service VM.
To build and run the applications, copy this repo to your VMs, run make in the directory that corresponds to the VM that you are running, and then follow the sample app guide in the acrn-hypervisor documentation.

View File

@ -92,13 +92,15 @@ size_t read_ivshmem_region(char *user_ptr, size_t size)
return ret;
//Determine if ivshmem region is set up
if (ivshmem_ptr) {
if ((ivshmem_ptr) && (size < REGION_SIZE - 1)) {
//Do the copy and zero out the ivshmem region
strncpy(user_ptr, ivshmem_ptr, size - 1);
user_ptr[size] = 0;
bzero(user_ptr, size);
strncpy(user_ptr, ivshmem_ptr, size);
ivshmem_ptr[size] = '\0';
user_ptr[size] = '\0';
ret = strlen(user_ptr);
bzero(ivshmem_ptr, ret);
bzero(ivshmem_ptr, size);
}
@ -130,13 +132,15 @@ size_t write_ivshmem_region(char *user_ptr, size_t size)
return ret;
//Determine if ivshmem region is set up
if (ivshmem_ptr) {
if ((ivshmem_ptr) && (size < REGION_SIZE - 1)) {
//Do the copy and zero out the user_ptr
strncpy(ivshmem_ptr, user_ptr, size - 1);
user_ptr[size] = 0;
bzero(ivshmem_ptr, size);
strncpy(ivshmem_ptr, user_ptr, size);
user_ptr[size] = '\0';
ivshmem_ptr[size] = '\0';
ret = strlen(ivshmem_ptr);
bzero(user_ptr, ret);
bzero(user_ptr, size);
}

View File

@ -64,7 +64,7 @@ int main(void)
//Read the data
bzero(data_buffer, BUFFERSIZE);
read(data_pipe, data_buffer, BUFFERSIZE);
read(data_pipe, data_buffer, BUFFERSIZE - 1);
//Get the sample stat
start_stat = strstr(data_buffer, "T:");

View File

@ -57,6 +57,8 @@ def create_hist():
return figure
def transform_data(data_string):
#Holds the transformed data
transformed_data_values = []
str_data = data_string.decode("utf-8")
@ -90,4 +92,4 @@ if __name__ == '__main__':
web_sem = ipc.Semaphore("/pyserversem", 0, 0o0774)
#Run the webserver
app.run(host="0.0.0.0", port=80, debug=True)
app.run(host="0.0.0.0", port=80, debug=False)

View File

@ -92,13 +92,15 @@ size_t read_ivshmem_region(char *user_ptr, size_t size)
return ret;
//Determine if ivshmem region is set up
if (ivshmem_ptr) {
if ((ivshmem_ptr) && (size < REGION_SIZE - 1)) {
//Do the copy and zero out the ivshmem region
strncpy(user_ptr, ivshmem_ptr, size - 1);
user_ptr[size] = 0;
bzero(user_ptr, size);
strncpy(user_ptr, ivshmem_ptr, size);
ivshmem_ptr[size] = '\0';
user_ptr[size] = '\0';
ret = strlen(user_ptr);
bzero(ivshmem_ptr, ret);
bzero(ivshmem_ptr, size);
}
@ -130,13 +132,15 @@ size_t write_ivshmem_region(char *user_ptr, size_t size)
return ret;
//Determine if ivshmem region is set up
if (ivshmem_ptr) {
if ((ivshmem_ptr) && (size < REGION_SIZE - 1)){
//Do the copy and zero out the user_ptr
strncpy(ivshmem_ptr, user_ptr, size - 1);
user_ptr[size] = 0;
bzero(ivshmem_ptr, size);
strncpy(ivshmem_ptr, user_ptr, size);
user_ptr[size] = '\0';
ivshmem_ptr[size] = '\0';
ret = strlen(ivshmem_ptr);
bzero(user_ptr, ret);
bzero(user_ptr, size);
}

View File

@ -44,7 +44,7 @@ int main(void)
latencies.latenciesCount++;
//Dump the data if we have enough data points
if (latencies.latenciesCount % 100 == 0) {
if ((latencies.latenciesCount > 0) && (latencies.latenciesCount % 100 == 0)) {
dump_data(latencies, shm_addr);