forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kubevirt#8624 from zhuchenwang/vsock_rest
Expose API to access VMI via VSOCK
- Loading branch information
Showing
71 changed files
with
2,576 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package rest | ||
|
||
import ( | ||
"fmt" | ||
|
||
restful "github.com/emicklei/go-restful" | ||
"k8s.io/apimachinery/pkg/api/errors" | ||
|
||
v1 "kubevirt.io/api/core/v1" | ||
"kubevirt.io/client-go/kubecli" | ||
"kubevirt.io/client-go/log" | ||
|
||
"kubevirt.io/kubevirt/pkg/util" | ||
) | ||
|
||
func (app *SubresourceAPIApp) VSOCKRequestHandler(request *restful.Request, response *restful.Response) { | ||
streamer := NewRawStreamer( | ||
app.FetchVirtualMachineInstance, | ||
validateVMIForVSOCK, | ||
app.virtHandlerDialer(func(vmi *v1.VirtualMachineInstance, conn kubecli.VirtHandlerConn) (string, error) { | ||
return conn.VSOCKURI(vmi, request.QueryParameter("port")) | ||
}), | ||
) | ||
|
||
streamer.Handle(request, response) | ||
} | ||
|
||
func validateVMIForVSOCK(vmi *v1.VirtualMachineInstance) *errors.StatusError { | ||
if !util.IsAutoAttachVSOCK(vmi) { | ||
err := fmt.Errorf("VSOCK is not attached.") | ||
log.Log.Object(vmi).Reason(err).Error("Can't establish Vsock connection.") | ||
return errors.NewBadRequest(err.Error()) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.