Skip to content

Commit 595e1a5

Browse files
azenlaSweetsurbhi88
authored andcommitted
prototype of device database api
1 parent cd5902e commit 595e1a5

2 files changed

Lines changed: 68 additions & 22 deletions

File tree

protect/control/v1/common.proto

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ message AnnotationSpec {
151151
}
152152

153153
message DeviceReferenceSpec {
154-
string name = 1;
154+
string id = 1;
155155
}
156156

157157
message WorkloadBlockDeviceSpec {
@@ -489,10 +489,41 @@ message OciImageProgressIndicationCompleted {
489489
bool is_bytes = 3;
490490
}
491491

492-
message DeviceInfo {
492+
message PciDeviceSpec {
493+
string location = 1;
494+
bool permissive = 2;
495+
}
496+
497+
message BlockDeviceSpec {
498+
string device_path = 1;
499+
}
500+
501+
message DeviceSpec {
493502
string name = 1;
494-
bool claimed = 2;
495-
string owner_zone = 3;
503+
oneof device_type {
504+
PciDeviceSpec pci = 2;
505+
BlockDeviceSpec block = 3;
506+
}
507+
repeated string modules = 4;
508+
repeated KernelModuleParameter module_parameters = 5;
509+
}
510+
511+
enum DeviceState {
512+
DEVICE_STATE_UNKNOWN = 0;
513+
DEVICE_STATE_AVAILABLE = 1;
514+
DEVICE_STATE_TAINTED = 2;
515+
DEVICE_STATE_USED = 3;
516+
}
517+
518+
message DeviceStatus {
519+
DeviceState state = 1;
520+
string zone_id = 2;
521+
}
522+
523+
message Device {
524+
string id = 1;
525+
DeviceSpec spec = 2;
526+
DeviceStatus status = 3;
496527
}
497528

498529
message ZoneScratchDiskSpec {
@@ -564,14 +595,3 @@ message OciRegistryAuthentication {
564595
string registry_token = 4;
565596
}
566597
}
567-
568-
message PciDevice {
569-
PciDeviceState state = 1;
570-
}
571-
572-
enum PciDeviceState {
573-
PCI_DEVICE_STATE_CLEAN = 0;
574-
PCI_DEVICE_STATE_DIRTY = 1;
575-
PCI_DEVICE_STATE_SCRUB = 2;
576-
PCI_DEVICE_STATE_BUSY = 3;
577-
}

protect/control/v1/control.proto

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ service ControlService {
99
rpc SnoopIdm(SnoopIdmRequest) returns (stream SnoopIdmReply);
1010
rpc GetHostCpuTopology(GetHostCpuTopologyRequest) returns (GetHostCpuTopologyReply);
1111

12+
rpc CreateDevice(CreateDeviceRequest) returns (CreateDeviceReply);
1213
rpc ListDevices(ListDevicesRequest) returns (ListDevicesReply);
14+
rpc UpdateDeviceState(UpdateDeviceStateRequest) returns (UpdateDeviceStateReply);
15+
rpc DestroyDevice(DestroyDeviceRequest) returns (DestroyDeviceReply);
16+
rpc ResolveDeviceIds(ResolveDeviceIdsRequest) returns (ResolveDeviceIdsReply);
1317

1418
rpc CreateNetworkReservation(CreateNetworkReservationRequest) returns (CreateNetworkReservationReply);
1519
rpc DestroyNetworkReservation(DestroyNetworkReservationRequest) returns (DestroyNetworkReservationReply);
@@ -55,7 +59,6 @@ service ControlService {
5559
rpc SetHostPowerManagementPolicy(SetHostPowerManagementPolicyRequest) returns (SetHostPowerManagementPolicyReply);
5660

5761
rpc DialNetworkSocket(stream DialNetworkSocketRequest) returns (stream DialNetworkSocketReply);
58-
rpc DeviceStateUpdate(DeviceStateRequest) returns (DeviceStateReply);
5962
}
6063

6164
message GetHostStatusRequest {}
@@ -70,12 +73,12 @@ message GetHostStatusReply {
7073
optional uint64 hyp_free_mem = 7;
7174
}
7275

73-
message DeviceStateRequest {
74-
string name = 1;
75-
PciDevice state = 2;
76+
message UpdateDeviceStateRequest {
77+
string id = 1;
78+
DeviceState state = 2;
7679
}
7780

78-
message DeviceStateReply {}
81+
message UpdateDeviceStateReply {}
7982

8083
message CreateZoneRequest {
8184
ZoneSpec spec = 1;
@@ -415,7 +418,7 @@ message WorkloadChangedEvent {
415418
}
416419

417420
message DeviceChangedEvent {
418-
DeviceReferenceSpec device = 1;
421+
Device device = 1;
419422
}
420423

421424
message ReadZoneMetricsRequest {
@@ -489,7 +492,8 @@ message ListImagesReply {
489492
message ListDevicesRequest {}
490493

491494
message ListDevicesReply {
492-
repeated DeviceInfo devices = 1;
495+
reserved 1;
496+
repeated Device devices = 2;
493497
}
494498

495499
message GetHostCpuTopologyRequest {}
@@ -626,3 +630,25 @@ message DialNetworkSocketData {
626630
message DialNetworkSocketReply {
627631
DialNetworkSocketData data = 1;
628632
}
633+
634+
message CreateDeviceRequest {
635+
DeviceSpec spec = 1;
636+
}
637+
638+
message CreateDeviceReply {
639+
string id = 1;
640+
}
641+
642+
message DestroyDeviceRequest {
643+
string id = 1;
644+
}
645+
646+
message DestroyDeviceReply {}
647+
648+
message ResolveDeviceIdsRequest {
649+
string name = 1;
650+
}
651+
652+
message ResolveDeviceIdsReply {
653+
string device_ids = 1;
654+
}

0 commit comments

Comments
 (0)