Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two fixes for virtio-scsi #1

Open
wants to merge 3 commits into
base: hostos-stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions board-qemu/slof/virtio-scsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ FALSE CONSTANT virtio-scsi-debug
: decode-unit 2 hex64-decode-unit ;
: encode-unit 2 hex64-encode-unit ;

FALSE VALUE initialized?

virtio-setup-vd VALUE virtiodev

STRUCT \ virtio-scsi-config
Expand Down Expand Up @@ -174,13 +172,28 @@ scsi-close \ no further scsi words required
THEN
;

: shutdown ( -- )
initialized? IF
my-phandle node>path open-dev ?dup IF
virtiodev virtio-scsi-shutdown
close-dev
THEN
FALSE to initialized?
0 VALUE open-count

: open ( -- )
open-count 0= IF
open 0= IF false EXIT THEN
virtiodev virtio-scsi-init
0= IF
1 to open-count true
ELSE ." virtio-scsi initialization failed !" cr false THEN
ELSE
open-count 1 + to open-count
true
THEN
;

: close ( -- )
open-count 0> IF
open-count 1 - dup to open-count
0= IF
virtiodev virtio-scsi-shutdown
close
THEN
THEN
;

Expand All @@ -190,13 +203,8 @@ scsi-close \ no further scsi words required
my-self >r
dup to my-self
\ Scan the VSCSI bus:
virtiodev virtio-scsi-init
0= IF
scsi-find-disks
setup-alias
TRUE to initialized?
['] shutdown add-quiesce-xt
THEN
scsi-find-disks
setup-alias
\ Close the temporary instance:
close-node
r> to my-self
Expand Down
4 changes: 2 additions & 2 deletions lib/libvirtio/virtio-scsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct virtio_scsi_req_cmd {
uint8_t prio;
uint8_t crn;
char cdb[VIRTIO_SCSI_CDB_SIZE];
};
} __attribute__((packed));

/* This is the first element of the "in" scatter-gather list. */
struct virtio_scsi_resp_cmd {
Expand All @@ -57,7 +57,7 @@ struct virtio_scsi_resp_cmd {
uint8_t status;
uint8_t response;
uint8_t sense[VIRTIO_SCSI_SENSE_SIZE];
};
} __attribute__((packed));

extern int virtioscsi_init(struct virtio_device *dev);
extern void virtioscsi_shutdown(struct virtio_device *dev);
Expand Down
Loading