Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Verlässliche Systemsoftware
projects
osv
Commits
11b9e3e5
Commit
11b9e3e5
authored
12 years ago
by
Dor Laor
Browse files
Options
Downloads
Patches
Plain Diff
Implement a basic virtio make request function and add
a tests that uses it and adds plenty of block requests to the host.
parent
e6fddd63
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
drivers/virtio-blk.cc
+26
-5
26 additions, 5 deletions
drivers/virtio-blk.cc
drivers/virtio-blk.hh
+6
-0
6 additions, 0 deletions
drivers/virtio-blk.hh
loader.cc
+3
-1
3 additions, 1 deletion
loader.cc
with
35 additions
and
6 deletions
drivers/virtio-blk.cc
+
26
−
5
View file @
11b9e3e5
...
...
@@ -40,17 +40,38 @@ namespace virtio {
return
true
;
}
void
virtio_blk
::
make_virtio_req
(
sglist
*
sg
,
u64
sector
)
{
virtio_blk_outhdr
*
hdr
=
reinterpret_cast
<
virtio_blk_outhdr
*>
(
malloc
(
sizeof
(
virtio_blk_outhdr
)));
hdr
->
type
=
VIRTIO_BLK_T_OUT
;
hdr
->
ioprio
=
0
;
hdr
->
sector
=
sector
;
sg
->
add
(
mmu
::
virt_to_phys
(
hdr
),
sizeof
(
struct
virtio_blk_outhdr
),
true
);
virtio_blk_res
*
res
=
reinterpret_cast
<
virtio_blk_res
*>
(
malloc
(
sizeof
(
virtio_blk_res
)));
res
->
status
=
0
;
sg
->
add
(
mmu
::
virt_to_phys
(
res
),
sizeof
(
struct
virtio_blk_res
));
}
void
virtio_blk
::
test
()
{
int
i
;
sglist
*
sg
=
new
sglist
();
for
(
i
=
0
;
i
<
10
;
i
++
)
{
debug
(
"test virtio blk"
);
for
(
i
=
0
;
i
<
200
;
i
++
)
{
sglist
*
sg
=
new
sglist
();
void
*
buf
=
malloc
(
page_size
);
memset
(
buf
,
0
,
page_size
);
sg
->
add
(
mmu
::
virt_to_phys
(
buf
),
page_size
);
make_virtio_req
(
sg
,
i
*
8
*
512
);
if
(
!
_queues
[
0
]
->
add_buf
(
sg
,
2
,
1
,
sg
))
{
debug
(
fmt
(
"virtio blk test - added too many %i, expected"
)
%
i
);
break
;
}
}
debug
(
"test virtio blk"
);
_queues
[
0
]
->
add_buf
(
sg
,
0
,
i
,
nullptr
);
_queues
[
0
]
->
kick
();
_queues
[
0
]
->
kick
();
debug
(
"test end"
);
}
...
...
This diff is collapsed.
Click to expand it.
drivers/virtio-blk.hh
+
6
−
0
View file @
11b9e3e5
...
...
@@ -129,6 +129,10 @@ namespace virtio {
u32
residual
;
};
struct
virtio_blk_res
{
u8
status
;
};
virtio_blk
();
virtual
~
virtio_blk
();
...
...
@@ -136,6 +140,8 @@ namespace virtio {
virtual
u32
get_driver_features
(
void
)
{
return
((
1
<<
VIRTIO_BLK_F_SIZE_MAX
));
}
void
make_virtio_req
(
sglist
*
sg
,
u64
sector
);
void
test
();
private
:
...
...
This diff is collapsed.
Click to expand it.
loader.cc
+
3
−
1
View file @
11b9e3e5
...
...
@@ -274,11 +274,13 @@ void* do_main_thread(void *_args)
Driver
*
vnet
=
new
virtio
::
virtio_net
();
DriverFactory
::
Instance
()
->
RegisterDriver
(
vnet
);
Driver
*
vblk
=
new
virtio
::
virtio_blk
();
virtio
::
virtio_blk
*
vblk
=
new
virtio
::
virtio_blk
();
DriverFactory
::
Instance
()
->
RegisterDriver
(
vblk
);
DeviceFactory
::
Instance
()
->
InitializeDrivers
();
vblk
->
test
();
DriverFactory
::
Instance
()
->
Destroy
();
auto
t1
=
clock
::
get
()
->
time
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment