Skip to content

Commit 476dd37

Browse files
committed
tbs
Signed-off-by: Babis Chalios <[email protected]>
1 parent dd70a65 commit 476dd37

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

src/vmm/src/devices/virtio/block/virtio/device.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::io::{Seek, SeekFrom};
1212
use std::os::linux::fs::MetadataExt;
1313
use std::path::PathBuf;
1414
use std::sync::Arc;
15+
use std::time::Duration;
1516

1617
use block_io::FileEngine;
1718
use serde::{Deserialize, Serialize};
@@ -423,6 +424,11 @@ impl VirtioBlock {
423424
}
424425

425426
used_any = true;
427+
if self.id == "scratch"
428+
&& (request.r#type == RequestType::In || request.r#type == RequestType::Out)
429+
{
430+
std::thread::sleep(Duration::from_millis(60));
431+
}
426432
request.process(&mut self.disk, head.index, mem, &self.metrics)
427433
}
428434
Err(err) => {

src/vmm/src/devices/virtio/block/virtio/event_handler.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,13 @@ impl MutEventSubscriber for VirtioBlock {
8787
match source {
8888
Self::PROCESS_ACTIVATE => self.process_activate_event(ops),
8989
Self::PROCESS_QUEUE => {
90-
info!("Started processing Block queue");
90+
let tstamp = std::time::Instant::now();
9191
self.process_queue_event();
92-
info!("Stopped processing Block queue");
92+
info!(
93+
"block[{}]: processed queue for {} usec",
94+
&self.id,
95+
tstamp.elapsed().as_micros()
96+
);
9397
}
9498
Self::PROCESS_RATE_LIMITER => self.process_rate_limiter_event(),
9599
Self::PROCESS_ASYNC_COMPLETION => self.process_async_completion_event(),

src/vmm/src/devices/virtio/net/event_handler.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl MutEventSubscriber for Net {
9898
}
9999

100100
if self.is_activated() {
101-
info!("Started processing Net device event");
101+
let tstamp = std::time::Instant::now();
102102
match source {
103103
Self::PROCESS_ACTIVATE => self.process_activate_event(ops),
104104
Self::PROCESS_VIRTQ_RX => self.process_rx_queue_event(),
@@ -111,7 +111,10 @@ impl MutEventSubscriber for Net {
111111
self.metrics.event_fails.inc();
112112
}
113113
}
114-
info!("Stopped processing Net device event");
114+
info!(
115+
"net: processed queue for {} usec",
116+
tstamp.elapsed().as_micros()
117+
);
115118
} else {
116119
warn!(
117120
"Net: The device is not yet activated. Spurious event received: {:?}",

tests/integration_tests/functional/test_drive_virtio.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33
"""Tests for guest-side operations on /drives resources."""
44

5-
import concurrent
5+
import concurrent.futures
66
import os
77
import time
88

@@ -409,7 +409,7 @@ def run_fio(microvm, mode, block_size, test_output_dir, fio_engine="libaio"):
409409
.with_arg(f"--bs={block_size}")
410410
.with_arg(f"--size={BLOCK_DEVICE_SIZE_MB}M")
411411
.with_arg(f"--ioengine={fio_engine}")
412-
.with_arg("--iodepth=32")
412+
.with_arg("--iodepth=256")
413413
# Set affinity of the entire fio process to a set of vCPUs equal in size to number of workers
414414
.with_arg(
415415
f"--cpus_allowed={','.join(str(i) for i in range(microvm.vcpus_count))}"
@@ -431,17 +431,17 @@ def run_fio(microvm, mode, block_size, test_output_dir, fio_engine="libaio"):
431431
prepare_microvm_for_test(microvm)
432432

433433
with concurrent.futures.ThreadPoolExecutor() as executor:
434-
executor.submit(_run_fio, microvm, test_output_dir)
435-
436-
for _ in range(30):
437-
microvm.ssh.check_output("true")
438-
time.sleep(1)
434+
fio_future = executor.submit(_run_fio, microvm, cmd, test_output_dir)
435+
while not fio_future.done():
436+
microvm.ssh.check_output("true", timeout=1)
437+
fio_future.result()
439438

440439

441440
def _run_fio(microvm, cmd, test_output_dir):
442-
rc, _, stderr = microvm.ssh.run(f"cd /tmp; {cmd}")
443-
assert rc == 0, stderr
441+
rc, stdout, stderr = microvm.ssh.run(f"cd /tmp; {cmd}")
442+
assert rc == 0
444443
assert stderr == ""
444+
print(f"standard output: {stdout}")
445445

446446
microvm.ssh.scp_get("/tmp/fio.json", test_output_dir)
447447
microvm.ssh.scp_get("/tmp/*.log", test_output_dir)
@@ -460,22 +460,22 @@ def test_greedy_block(
460460
fio_block_size,
461461
fio_engine,
462462
io_engine,
463-
metrics,
464463
results_dir,
465464
):
466465
"""
467466
Make sure that a guest continuously using the block device
468467
doesn't starve a Network device
469468
"""
470469
vm = microvm_factory.build(guest_kernel_acpi, rootfs, monitor_memory=False)
470+
vm.jailer.extra_args.update({"no-seccomp": None})
471471
vm.spawn(log_level="Info", emit_metrics=False)
472472
vm.basic_config(vcpu_count=vcpus, mem_size_mib=1024)
473473
vm.add_net_iface()
474474

475475
# Add a secondary block device for testing
476476
fs = drive_tools.FilesystemFile(os.path.join(vm.fsfiles, "scratch"), 4096)
477-
vm.add_drive("scratch", fs.path, io_engine=io_engine)
477+
vm.add_drive("scratch2", fs.path, io_engine=io_engine)
478478

479479
vm.start()
480480

481-
cpu_util = run_fio(vm, fio_mode, fio_block_size, results_dir, fio_engine)
481+
run_fio(vm, fio_mode, fio_block_size, results_dir, fio_engine)

0 commit comments

Comments
 (0)