Skip to content

Remotevm UVM implementation#1023

Merged
dcantah merged 1 commit intomicrosoft:masterfrom
dcantah:remotevm-uvm
May 22, 2021
Merged

Remotevm UVM implementation#1023
dcantah merged 1 commit intomicrosoft:masterfrom
dcantah:remotevm-uvm

Conversation

@dcantah
Copy link
Contributor

@dcantah dcantah commented May 11, 2021

Add an implementation of the vm.UVM interface using the vmservice ttrpc
definitions.

Signed-off-by: Daniel Canter dcanter@microsoft.com

@dcantah dcantah requested a review from a team as a code owner May 11, 2021 00:27
@dcantah dcantah force-pushed the remotevm-uvm branch 4 times, most recently from 6cde672 to 7a47037 Compare May 12, 2021 18:26
@dcantah
Copy link
Contributor Author

dcantah commented May 12, 2021

@jstarks Was satisfying the almighty linter, ready for eyes again

@jstarks
Copy link
Member

jstarks commented May 18, 2021

Otherwise LGTM

@dcantah dcantah force-pushed the remotevm-uvm branch 2 times, most recently from a337f5f to 2c2ea85 Compare May 18, 2021 22:45
Comment on lines +16 to +28
f, err := ioutil.TempFile("", "")
if err != nil {
return nil, errors.Wrap(err, "failed to create temp file for unix socket")
}

if err := f.Close(); err != nil {
return nil, errors.Wrap(err, "failed to close temp file")
}

if err := os.Remove(f.Name()); err != nil {
return nil, errors.Wrap(err, "failed to delete temp file to free up name")
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the point of this just to get a unique path to use?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, could make a comment about this.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't care about putting these anywhere specific in case of issues where files aren't cleaned up or something? Maybe in the C:\ContainerPlatData dir like the container IO files or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should place them in a directory containerd maintains, but I'm not too worried about this in general. The way we setup the io channels is to just close the listener the second we accept a connection (which removes the socket file anyways).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The socket file itself is removed the second you'd close the listener, but the connection is still valid. For a quick hacked up example.

func echo(c net.Conn) {
	for {
		buf := make([]byte, 512)
		nr, err := c.Read(buf)
		if err != nil {
			log.Fatal(err)
		}

		data := buf[0:nr]
		fmt.Printf("Received: %v\n\n", string(data))
	}
}

func main() {
	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, syscall.SIGINT)

	l, err := net.Listen("unix", `/test.sock`)
	if err != nil {
		log.Fatal(err)
	}

	conn, err := l.Accept()
	if err != nil {
		log.Fatal(err)
	}

	// Socket file removed after this line, can still utilize the conn we have but the listeners
	// done for (can't accept any further conns).
	l.Close()

	go echo(conn)

	select {
	case <-sigChan:
		log.Print("Received signal, closing.")
	}
}

Where the listener we return in this func is eventually used is here: https://github.com/microsoft/hcsshim/blob/master/internal/gcs/iochannel.go#L14-L27

So I don't have many worries about socket files not being cleaned up.

Add an implementation of the vm.UVM interface using the vmservice ttrpc
definitions.

Fix up cpugroup HypervisorId type to be a uint64

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
@dcantah
Copy link
Contributor Author

dcantah commented May 19, 2021

@katiewasnothere Remedied, thanks!

Copy link

@katiewasnothere katiewasnothere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dcantah dcantah merged commit 91974a2 into microsoft:master May 22, 2021
princepereira pushed a commit to princepereira/hcsshim that referenced this pull request Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants