@@ -67,9 +67,16 @@ func (s *server) NVMeSubsystemDelete(ctx context.Context, in *pb.NVMeSubsystemDe
67
67
return & emptypb.Empty {}, nil
68
68
}
69
69
70
- func (s * server ) NVMeSubsystemUpdate (ctx context.Context , in * pb.NVMeSubsystemUpdateRequest ) (* pb.NVMeSubsystemUpdateResponse , error ) {
70
+ func (s * server ) NVMeSubsystemUpdate (ctx context.Context , in * pb.NVMeSubsystemUpdateRequest ) (* pb.NVMeSubsystem , error ) {
71
71
log .Printf ("NVMeSubsystemUpdate: Received from client: %v" , in )
72
- return & pb.NVMeSubsystemUpdateResponse {}, nil
72
+ subsystems [in .Subsystem .Id .Value ] = in .Subsystem
73
+ response := & pb.NVMeSubsystem {}
74
+ err := deepcopier .Copy (in .Subsystem ).To (response )
75
+ if err != nil {
76
+ log .Printf ("error: %v" , err )
77
+ return nil , err
78
+ }
79
+ return response , nil
73
80
}
74
81
75
82
func (s * server ) NVMeSubsystemList (ctx context.Context , in * pb.NVMeSubsystemListRequest ) (* pb.NVMeSubsystemListResponse , error ) {
@@ -89,7 +96,7 @@ func (s *server) NVMeSubsystemList(ctx context.Context, in *pb.NVMeSubsystemList
89
96
return & pb.NVMeSubsystemListResponse {Subsystem : Blobarray }, nil
90
97
}
91
98
92
- func (s * server ) NVMeSubsystemGet (ctx context.Context , in * pb.NVMeSubsystemGetRequest ) (* pb.NVMeSubsystemGetResponse , error ) {
99
+ func (s * server ) NVMeSubsystemGet (ctx context.Context , in * pb.NVMeSubsystemGetRequest ) (* pb.NVMeSubsystem , error ) {
93
100
log .Printf ("NVMeSubsystemGet: Received from client: %v" , in )
94
101
subsys , ok := subsystems [in .SubsystemId .Value ]
95
102
if ! ok {
@@ -109,7 +116,7 @@ func (s *server) NVMeSubsystemGet(ctx context.Context, in *pb.NVMeSubsystemGetRe
109
116
for i := range result {
110
117
r := & result [i ]
111
118
if r .Nqn == subsys .Nqn {
112
- return & pb.NVMeSubsystemGetResponse { Subsystem : & pb. NVMeSubsystem {Nqn : r .Nqn } }, nil
119
+ return & pb.NVMeSubsystem {Nqn : r .Nqn }, nil
113
120
}
114
121
}
115
122
msg := fmt .Sprintf ("Could not find NQN: %s" , subsys .Nqn )
@@ -154,10 +161,16 @@ func (s *server) NVMeControllerDelete(ctx context.Context, in *pb.NVMeController
154
161
return & emptypb.Empty {}, nil
155
162
}
156
163
157
- func (s * server ) NVMeControllerUpdate (ctx context.Context , in * pb.NVMeControllerUpdateRequest ) (* pb.NVMeControllerUpdateResponse , error ) {
164
+ func (s * server ) NVMeControllerUpdate (ctx context.Context , in * pb.NVMeControllerUpdateRequest ) (* pb.NVMeController , error ) {
158
165
log .Printf ("Received from client: %v" , in .Controller )
159
166
controllers [in .Controller .Id .Value ] = in .Controller
160
- return & pb.NVMeControllerUpdateResponse {}, nil
167
+ response := & pb.NVMeController {}
168
+ err := deepcopier .Copy (in .Controller ).To (response )
169
+ if err != nil {
170
+ log .Printf ("error: %v" , err )
171
+ return nil , err
172
+ }
173
+ return response , nil
161
174
}
162
175
163
176
func (s * server ) NVMeControllerList (ctx context.Context , in * pb.NVMeControllerListRequest ) (* pb.NVMeControllerListResponse , error ) {
@@ -169,13 +182,13 @@ func (s *server) NVMeControllerList(ctx context.Context, in *pb.NVMeControllerLi
169
182
return & pb.NVMeControllerListResponse {Controller : Blobarray }, nil
170
183
}
171
184
172
- func (s * server ) NVMeControllerGet (ctx context.Context , in * pb.NVMeControllerGetRequest ) (* pb.NVMeControllerGetResponse , error ) {
185
+ func (s * server ) NVMeControllerGet (ctx context.Context , in * pb.NVMeControllerGetRequest ) (* pb.NVMeController , error ) {
173
186
log .Printf ("Received from client: %v" , in .ControllerId )
174
187
controller , ok := controllers [in .ControllerId .Value ]
175
188
if ! ok {
176
189
return nil , fmt .Errorf ("error finding controller %s" , in .ControllerId .Value )
177
190
}
178
- return & pb.NVMeControllerGetResponse { Controller : controller }, nil
191
+ return & pb.NVMeController { Id : in . ControllerId , NvmeControllerId : controller . NvmeControllerId }, nil
179
192
}
180
193
181
194
func (s * server ) NVMeControllerStats (ctx context.Context , in * pb.NVMeControllerStatsRequest ) (* pb.NVMeControllerStatsResponse , error ) {
@@ -250,10 +263,16 @@ func (s *server) NVMeNamespaceDelete(ctx context.Context, in *pb.NVMeNamespaceDe
250
263
return & emptypb.Empty {}, nil
251
264
}
252
265
253
- func (s * server ) NVMeNamespaceUpdate (ctx context.Context , in * pb.NVMeNamespaceUpdateRequest ) (* pb.NVMeNamespaceUpdateResponse , error ) {
266
+ func (s * server ) NVMeNamespaceUpdate (ctx context.Context , in * pb.NVMeNamespaceUpdateRequest ) (* pb.NVMeNamespace , error ) {
254
267
log .Printf ("Received from client: %v" , in .Namespace )
255
268
namespaces [in .Namespace .Id .Value ] = in .Namespace
256
- return & pb.NVMeNamespaceUpdateResponse {}, nil
269
+ response := & pb.NVMeNamespace {}
270
+ err := deepcopier .Copy (in .Namespace ).To (response )
271
+ if err != nil {
272
+ log .Printf ("error: %v" , err )
273
+ return nil , err
274
+ }
275
+ return response , nil
257
276
}
258
277
259
278
func (s * server ) NVMeNamespaceList (ctx context.Context , in * pb.NVMeNamespaceListRequest ) (* pb.NVMeNamespaceListResponse , error ) {
@@ -296,7 +315,7 @@ func (s *server) NVMeNamespaceList(ctx context.Context, in *pb.NVMeNamespaceList
296
315
return nil , status .Errorf (codes .InvalidArgument , msg )
297
316
}
298
317
299
- func (s * server ) NVMeNamespaceGet (ctx context.Context , in * pb.NVMeNamespaceGetRequest ) (* pb.NVMeNamespaceGetResponse , error ) {
318
+ func (s * server ) NVMeNamespaceGet (ctx context.Context , in * pb.NVMeNamespaceGetRequest ) (* pb.NVMeNamespace , error ) {
300
319
log .Printf ("NVMeNamespaceGet: Received from client: %v" , in )
301
320
namespace , ok := namespaces [in .NamespaceId .Value ]
302
321
if ! ok {
@@ -305,7 +324,7 @@ func (s *server) NVMeNamespaceGet(ctx context.Context, in *pb.NVMeNamespaceGetRe
305
324
return nil , err
306
325
}
307
326
// TODO: do we even query SPDK to confirm if namespace is present?
308
- // return &pb.NVMeNamespaceGetResponse{Namespace: & namespace} , nil
327
+ // return namespace, nil
309
328
310
329
// fetch subsystems -> namespaces from server, match the nsid to find the corresponding namespace
311
330
subsys , ok := subsystems [namespace .SubsystemId .Value ]
@@ -328,7 +347,7 @@ func (s *server) NVMeNamespaceGet(ctx context.Context, in *pb.NVMeNamespaceGetRe
328
347
for j := range rr .Namespaces {
329
348
r := & rr .Namespaces [j ]
330
349
if uint32 (r .Nsid ) == namespace .HostNsid {
331
- return & pb.NVMeNamespaceGetResponse { Namespace : namespace }, nil
350
+ return & pb.NVMeNamespace { Id : namespace . Id , HostNsid : namespace . HostNsid }, nil
332
351
}
333
352
}
334
353
msg := fmt .Sprintf ("Could not find NSID: %d" , namespace .HostNsid )
@@ -385,9 +404,9 @@ func (s *server) VirtioBlkDelete(ctx context.Context, in *pb.VirtioBlkDeleteRequ
385
404
return & emptypb.Empty {}, nil
386
405
}
387
406
388
- func (s * server ) VirtioBlkUpdate (ctx context.Context , in * pb.VirtioBlkUpdateRequest ) (* pb.VirtioBlkUpdateResponse , error ) {
407
+ func (s * server ) VirtioBlkUpdate (ctx context.Context , in * pb.VirtioBlkUpdateRequest ) (* pb.VirtioBlk , error ) {
389
408
log .Printf ("Received from client: %v" , in )
390
- return & pb.VirtioBlkUpdateResponse {}, nil
409
+ return & pb.VirtioBlk {}, nil
391
410
}
392
411
393
412
func (s * server ) VirtioBlkList (ctx context.Context , in * pb.VirtioBlkListRequest ) (* pb.VirtioBlkListResponse , error ) {
@@ -407,7 +426,7 @@ func (s *server) VirtioBlkList(ctx context.Context, in *pb.VirtioBlkListRequest)
407
426
return & pb.VirtioBlkListResponse {Controller : Blobarray }, nil
408
427
}
409
428
410
- func (s * server ) VirtioBlkGet (ctx context.Context , in * pb.VirtioBlkGetRequest ) (* pb.VirtioBlkGetResponse , error ) {
429
+ func (s * server ) VirtioBlkGet (ctx context.Context , in * pb.VirtioBlkGetRequest ) (* pb.VirtioBlk , error ) {
411
430
log .Printf ("VirtioBlkGet: Received from client: %v" , in )
412
431
params := VhostGetControllersParams {
413
432
Name : fmt .Sprint ("VirtioBlk" , in .GetControllerId ()),
@@ -424,7 +443,7 @@ func (s *server) VirtioBlkGet(ctx context.Context, in *pb.VirtioBlkGetRequest) (
424
443
log .Print (msg )
425
444
return nil , status .Errorf (codes .InvalidArgument , msg )
426
445
}
427
- return & pb.VirtioBlkGetResponse { Controller : & pb. VirtioBlk {Name : result [0 ].Ctrlr } }, nil
446
+ return & pb.VirtioBlk {Name : result [0 ].Ctrlr }, nil
428
447
}
429
448
430
449
func (s * server ) VirtioBlkStats (ctx context.Context , in * pb.VirtioBlkStatsRequest ) (* pb.VirtioBlkStatsResponse , error ) {
@@ -470,9 +489,9 @@ func (s *server) VirtioScsiControllerDelete(ctx context.Context, in *pb.VirtioSc
470
489
return & emptypb.Empty {}, nil
471
490
}
472
491
473
- func (s * server ) VirtioScsiControllerUpdate (ctx context.Context , in * pb.VirtioScsiControllerUpdateRequest ) (* pb.VirtioScsiControllerUpdateResponse , error ) {
492
+ func (s * server ) VirtioScsiControllerUpdate (ctx context.Context , in * pb.VirtioScsiControllerUpdateRequest ) (* pb.VirtioScsiController , error ) {
474
493
log .Printf ("Received from client: %v" , in )
475
- return & pb.VirtioScsiControllerUpdateResponse {}, nil
494
+ return & pb.VirtioScsiController {}, nil
476
495
}
477
496
478
497
func (s * server ) VirtioScsiControllerList (ctx context.Context , in * pb.VirtioScsiControllerListRequest ) (* pb.VirtioScsiControllerListResponse , error ) {
@@ -492,7 +511,7 @@ func (s *server) VirtioScsiControllerList(ctx context.Context, in *pb.VirtioScsi
492
511
return & pb.VirtioScsiControllerListResponse {Controller : Blobarray }, nil
493
512
}
494
513
495
- func (s * server ) VirtioScsiControllerGet (ctx context.Context , in * pb.VirtioScsiControllerGetRequest ) (* pb.VirtioScsiControllerGetResponse , error ) {
514
+ func (s * server ) VirtioScsiControllerGet (ctx context.Context , in * pb.VirtioScsiControllerGetRequest ) (* pb.VirtioScsiController , error ) {
496
515
log .Printf ("VirtioScsiControllerGet: Received from client: %v" , in )
497
516
params := VhostGetControllersParams {
498
517
Name : fmt .Sprint ("OPI-VirtioScsi" , in .GetControllerId ()),
@@ -509,7 +528,7 @@ func (s *server) VirtioScsiControllerGet(ctx context.Context, in *pb.VirtioScsiC
509
528
log .Print (msg )
510
529
return nil , status .Errorf (codes .InvalidArgument , msg )
511
530
}
512
- return & pb.VirtioScsiControllerGetResponse { Controller : & pb. VirtioScsiController {Name : result [0 ].Ctrlr } }, nil
531
+ return & pb.VirtioScsiController {Name : result [0 ].Ctrlr }, nil
513
532
}
514
533
515
534
func (s * server ) VirtioScsiControllerStats (ctx context.Context , in * pb.VirtioScsiControllerStatsRequest ) (* pb.VirtioScsiControllerStatsResponse , error ) {
@@ -562,9 +581,9 @@ func (s *server) VirtioScsiLunDelete(ctx context.Context, in *pb.VirtioScsiLunDe
562
581
return & emptypb.Empty {}, nil
563
582
}
564
583
565
- func (s * server ) VirtioScsiLunUpdate (ctx context.Context , in * pb.VirtioScsiLunUpdateRequest ) (* pb.VirtioScsiLunUpdateResponse , error ) {
584
+ func (s * server ) VirtioScsiLunUpdate (ctx context.Context , in * pb.VirtioScsiLunUpdateRequest ) (* pb.VirtioScsiLun , error ) {
566
585
log .Printf ("Received from client: %v" , in )
567
- return & pb.VirtioScsiLunUpdateResponse {}, nil
586
+ return & pb.VirtioScsiLun {}, nil
568
587
}
569
588
570
589
func (s * server ) VirtioScsiLunList (ctx context.Context , in * pb.VirtioScsiLunListRequest ) (* pb.VirtioScsiLunListResponse , error ) {
@@ -584,7 +603,7 @@ func (s *server) VirtioScsiLunList(ctx context.Context, in *pb.VirtioScsiLunList
584
603
return & pb.VirtioScsiLunListResponse {Lun : Blobarray }, nil
585
604
}
586
605
587
- func (s * server ) VirtioScsiLunGet (ctx context.Context , in * pb.VirtioScsiLunGetRequest ) (* pb.VirtioScsiLunGetResponse , error ) {
606
+ func (s * server ) VirtioScsiLunGet (ctx context.Context , in * pb.VirtioScsiLunGetRequest ) (* pb.VirtioScsiLun , error ) {
588
607
log .Printf ("VirtioScsiLunGet: Received from client: %v" , in )
589
608
params := VhostGetControllersParams {
590
609
Name : fmt .Sprint ("OPI-VirtioScsi" , in .GetControllerId ()),
@@ -601,7 +620,7 @@ func (s *server) VirtioScsiLunGet(ctx context.Context, in *pb.VirtioScsiLunGetRe
601
620
log .Print (msg )
602
621
return nil , status .Errorf (codes .InvalidArgument , msg )
603
622
}
604
- return & pb.VirtioScsiLunGetResponse { Lun : & pb. VirtioScsiLun {Bdev : result [0 ].Ctrlr } }, nil
623
+ return & pb.VirtioScsiLun {Bdev : result [0 ].Ctrlr }, nil
605
624
}
606
625
607
626
func (s * server ) VirtioScsiLunStats (ctx context.Context , in * pb.VirtioScsiLunStatsRequest ) (* pb.VirtioScsiLunStatsResponse , error ) {
0 commit comments