Commit 751159ba authored by SIMONIN Matthieu's avatar SIMONIN Matthieu
Browse files

WiP

parent 1fdd2cd5
......@@ -76,5 +76,5 @@
},
"editor.formatOnSave": true,
"clang-format.assumeFilename": "${workspaceRoot}/.clang-format",
"editor.tabSize": 2,
"python.formatting.provider": "black",
}
\ No newline at end of file
......@@ -56,7 +56,7 @@ configure_file(examples/benchs/nova_cluster.xml examples/benchs/nova_cluster.xml
add_dependencies(gettimeofday fake-vm)
# Qemus
configure_file(examples/qemus/boot_and_log.sh examples/qemus/boot_and_log.sh COPYONLY)
configure_file(examples/qemus/boot.py examples/qemus/boot.py COPYONLY)
configure_file(examples/qemus/deployment.xml examples/qemus/deployment.xml COPYONLY)
configure_file(examples/qemus/nova_cluster.xml examples/qemus/nova_cluster.xml COPYONLY)
......
......@@ -223,4 +223,5 @@ done
vm = TansivVM(ip_tantap, ip_management, qemu_cmd=qemu_cmd, qemu_image=qemu_image)
with tempfile.TemporaryDirectory() as tmp:
LOGGER.info(f"Launching in {tmp}")
vm.start(working_dir=Path(tmp))
\ No newline at end of file
......@@ -63,6 +63,9 @@ IP=$1
MAC=$2
MAC2=$3
DESCRIPTOR=${MAC:(-2)}
DESCRIPTOR2=${MAC2:(-2)}
VM_NAME="vm-${MAC//:/-}"
# A decent key to use
......@@ -98,9 +101,15 @@ cat <<EOF > $CLOUD_INIT_DIR/network-config
version: 2
ethernets:
ens3:
dhcp4: true
addresses: [192.168.120.${DESCRIPTOR}/24]
gateway4: 192.168.120.1
dhcp4: false
dhcp6: false
ens4:
dhcp4: true
addresses: [192.168.121.${DESCRIPTOR2}/24]
gateway4: 192.168.120.1
dhcp4: false
dhcp6: false
EOF
......@@ -112,8 +121,8 @@ VM_IMAGE=$VM_NAME.qcow2
# start on the base one
# VM_IMAGE=debian10-x64-min.qcow2
TAP_NAME=tap${MAC:(-2)}
TAP2_NAME=tap${MAC2:(-2)}
TAP_NAME=tap$DESCRIPTOR
TAP2_NAME=tap$DESCRIPTOR2
$QEMU \
--icount shift=1,sleep=on \
-rtc clock=vm \
......
......@@ -4,18 +4,16 @@
<actor host="nova-1.lyon.grid5000.fr" function="vsg_vm">
<argument value="192.168.120.10"/> <!-- how simgrid knows me-->
<argument value="./examples/qemus/boot_and_log.sh"/>
<argument value="192.168.120.10"/> <!-- how vsg knows me-->
<argument value="52:54:00:00:00:10"/> <!-- my mac address so that the dhcp give the above IP -->
<argument value="52:54:00:00:01:20"/> <!-- secondary mac address-->
<argument value="./examples/qemus/boot.py"/>
<argument value="192.168.120.10/24"/> <!-- how vsg knows me-->
<argument value="172.16.0.10/24"/> <!-- management -->
</actor>
<actor host="nova-2.lyon.grid5000.fr" function="vsg_vm">
<argument value="192.168.120.11"/> <!-- how simgrid knows me-->
<argument value="./examples/qemus/boot_and_log.sh"/>
<argument value="192.168.120.11"/> <!-- how vsg knows me-->
<argument value="52:54:00:00:00:11"/> <!-- my mac address so that the dhcp give the above IP -->
<argument value="52:54:00:00:01:21"/> <!-- secondary mac address -->
<argument value="./examples/qemus/boot.py"/>
<argument value="192.168.120.11/24"/> <!-- how vsg knows me-->
<argument value="172.16.0.11/24"/> <!-- management -->
</actor>
</platform>
\ No newline at end of file
#include "log.h"
#include "vsg.h"
#include <stdio.h>
#include <stdlib.h>
/*
*
* Mimic a sink
* - first version is a sink for the vsg protocol not
* an UDP sink adapted for the vsg protocol
*
*
*/
int main(int argc, char *argv[]) {
char *myself = argv[1];
int vsg_socket = vsg_connect();
struct vsg_time previous_deadline;
struct vsg_time next_deadline;
uint64_t _id = 0;
while (1) {
_id++;
uint32_t order;
// TODO(msimonin): we need to define the src header length in the protocol
// at some point.
int dest_size = 3;
// printf("SINK] Waiting coordinator order\n");
vsg_recv_order(vsg_socket, &order);
struct vsg_time deadline = {0, 1};
struct vsg_time offset = {0, 20};
switch (order) {
case VSG_GO_TO_DEADLINE: {
vsg_at_deadline_recv(vsg_socket, &deadline);
previous_deadline = next_deadline;
next_deadline = deadline;
/* Don't do anything here.
-- this yields to the qemu process until it declares the same
*/
printf("SINK] -- deadline received=%ld.%06ld\n", deadline.seconds,
deadline.useconds);
// send some message
// we send message only if there some time [previous_deadline,
// next_deadline] isn't empty
if (!vsg_time_eq(previous_deadline, next_deadline)) {
char message[15];
sprintf(message, "fromsink_%05d", _id);
// send this somewhere
// the addr_in is important since the coordinator will route according
// to this the port is random currently: we dispatch inside qemu
// according to the src port
struct vsg_addr dest = {inet_addr("127.0.0.1"), htons(4321)};
// addr and port where the server (sink) is listening
// there is actually no server running this but we mimic the
// corresponding behaviour
struct vsg_addr src = {inet_addr(myself), htons(1234)};
struct vsg_packet packet = {
.size = sizeof(message) + 1, .dest = dest, .src = src};
struct vsg_send_packet send_packet = {.send_time = next_deadline,
.packet = packet};
vsg_send_send(vsg_socket, send_packet, message);
}
// --
vsg_at_deadline_send(vsg_socket);
break;
}
case VSG_DELIVER_PACKET: {
/* First receive the size of the payload. */
struct vsg_packet packet = {0};
vsg_deliver_recv_1(vsg_socket, &packet);
/* Second get the vsg payload = src + message. */
char message[packet.size];
vsg_deliver_recv_2(vsg_socket, message, packet.size);
struct in_addr addr = {packet.dest.addr};
printf("SINK] -- Decoded dest=%s\n", inet_ntoa(addr));
printf("SINK] -- Decoded message=%s\n", message);
break;
}
default:
printf("SINK] error: unknown message\n");
break;
}
}
return 0;
}
\ No newline at end of file
......@@ -5,7 +5,7 @@
#include <stdbool.h>
#include <stdint.h>
#define CONNECTION_SOCKET_NAME "simgrid_connection_socket"
#define CONNECTION_SOCKET_NAME "/tmp/simgrid_connection_socket"
/* Messages types */
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment