Skip to content

Instantly share code, notes, and snippets.

View MatiasVara's full-sized avatar
😀
Focusing

Matias Ezequiel Vara Larsen MatiasVara

😀
Focusing
View GitHub Profile
for i in 1000 200 120 50 20 10 2;
do
paplay --latency-ms=$i 44100_s16_2chan_file.wav &
PID=$!
sleep 1
echo "Latency $i 44100 server:"
sudo perf stat -p `pidof pipewire-uninstalled` --timeout 5000
echo "latency $i 44100 client:"
sudo perf stat -p $PID --timeout 5000
kill -9 $PID
import asyncio
from qemu.qmp import QMPClient
import argparse
from subprocess import call
import os
async def main():
parser = argparse.ArgumentParser(description='Pin QEMU vCPUs to physical CPUs')
parser.add_argument('-s', '--server', type=str, required=True, help='QMP server path or address:port')
parser.add_argument('cpu', type=int, nargs='+', help='Physical CPUs IDs')
@MatiasVara
MatiasVara / rwlock_example.rs
Created August 13, 2023 21:24
This example shows the use of rwlock, arc and threading.
// share ownership across multiple threads
// https://doc.rust-lang.org/book/ch16-03-shared-state.html
//
use std::thread;
use std::sync::{Arc,RwLock};
struct User {
index: u32,
}
@MatiasVara
MatiasVara / async_example.rs
Last active August 13, 2023 14:11
This is just an example of async in Rust but it may be wrong. I would like to have something that executes in its own context without using a thread.
use std::time::Duration;
use async_std::task;
use std::{thread, time};
// this is something that will take some time
// to execute so we execute it as an async function
// to not block the main thread. This function must not block
async fn do_sleep(val: u32) {
task::sleep(Duration::from_secs(3)).await;
println!("hello, world! {}", val);
@MatiasVara
MatiasVara / gist:64dad9f50787bae9718f2c860ec9cc08
Last active August 2, 2023 08:25
Get descriptor content from vq from the qemu monitor. The VM shall be stopped otherwise the content could not be correct. A better way to do this is by using gdb.
(qemu) info virtio
/machine/peripheral-anon/device[2]/virtio-backend [virtio-blk]
/machine/peripheral-anon/device[1]/virtio-backend [virtio-sound]
/machine/peripheral-anon/device[0]/virtio-backend [virtio-net]
(qemu) info virtio-queue-element /machine/peripheral-anon/device[1]/virtio-backend 2
/machine/peripheral-anon/device[1]/virtio-backend:
device_name: virtio-sound
index: 12
desc:
descs:
syntax on
filetype plugin indent on
command Cleanit %s/\s\+$//e
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
autocmd BufWritePre *.pas %s/\s\+$//e
" On pressing tab, insert 4 spaces
set expandtab
@MatiasVara
MatiasVara / mpi_reduce_on_toro.md
Last active March 30, 2023 11:38
This gists presents how to run the MPIReduce example on Toro

You require to install docker and KVM before to run these commands:

docker pull torokernel/toro-kernel-dev-debian-10
docker run --privileged --rm -it torokernel/toro-kernel-dev-debian-10
cd examples/MPI
make
../CloudIt.sh MpiReduce
@MatiasVara
MatiasVara / docker-push-pull.md
Created January 30, 2023 22:35
This gist explains how to pull and then push a image to docker hub

This is the procedure to push an image to a repository that the user has the right to access, e.g., organization.

docker login
docker pull torokernel/toro-kernel-dev-debian-10
docker build --no-cache -t torokernel/toro-kernel-dev-debian-10 .
docker push torokernel/toro-kernel-dev-debian-10
@MatiasVara
MatiasVara / init.sh
Last active November 20, 2022 22:12
This gist enables to build a minimal initramfs with a shell by relying on busybox. This only requires the busybox binary. The busybox binary must be statically linked (see https://gist.github.com/chrisdone/02e165a0004be33734ac2334f215380e).
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
echo -e "\nBoot took $(cut -d' ' -f1 /proc/uptime) seconds\n"
setsid cttyhack sh
exec /bin/sh
@MatiasVara
MatiasVara / run-and-deploy-linux-hvm-guest-with-xl.md
Last active December 9, 2022 13:16
This gist explains how to build Linux and deploy it as a Xen HVM guest by using xl

Introduction

This gist aims at building Linux from source-code and deploying it as HVM guest in Xen by using xl.

Building Linux

We use v5.10.17 tag (13b6016). We first build .config by issuing:

make localmodconfig

To enable debug symbols, you can set:

CONFIG_DEBUG_INFO_NONE=y