 Thank you. Thank you. Thank you, Candice. Hello, everyone. Again, my name is Watson. And I'm here today to tell you about how to set up an environment so that you can write Linux kernel in in Rust. So this is what we're going to cover today. I'll do a brief introduction and status update. Then I'm going to tell you how to set up the environment from a fresh install. So I will have a VM, Ubuntu VM run in and we'll start from there. And then some some conclusions after that. My video is posted at the moment. I'm not sure if you can, okay it came back. I hope it's still working. So a quick intro on Rust for Linux. Our goal is to make Rust a first class language for Linux kernel development. There is a trim down version of our patch series that is planned to be merged in in 6.1, which should be the next couple weeks. So we're very excited to see it being merged. The code that I'm going to show you is from our development branch. But our expectation is that once it's merged you can you can do something very similar in just regular mainline upstream Linux kernel checkouts. We've actually had already three series on Rust for Linux in the mentorship series, three sessions. The last one I presented and was how to write modules. And then we went through the steps to write these modules, but we started from a VM that was all set up. So this session is a prequel to that. So what we're going to work here is how to get to that state where we can write code and compile it and run it on QMU with vzbox image. So this is the plan for today. Sort of already mentioned this but we'll start from a pressure multi-installation. We'll fact some source code, we'll install tools and libraries. Then we're going to build everything that you need to build to test the kernel. Then we boot with QMU and vzbox and then also attach gdb2h to show how we can set breakpoints and inspect some states of the kernel as it runs. Then if we have time I can also show some Rust analyzer related stuff which is this plugin or this language server that allows us to introspect into the code and it's actually very, very cool and works with different ID. So I'm going to show it to you just through your code. So with that, let's switch to the VM running Google 2. One thing that I should say again is already mentioned but I'm going to reiterate it is if you have questions I'm happy to take them throughout the presentation. So let me share the VM here. So what we have here is a fresh install of Ubuntu. There are only two things that I installed that didn't come in it by default and this is like a minimal installation. So I started installing gcc and make and I had to install them because I wanted to install some guest VM additions or enlightenment to this and it required that to compile the kernel modules. So let's get started. So we have here a fresh install. I'm going to create a source directory and I'm going to clone the source code for Rust Prolinux here. One thing that I'm going to do here, which you wouldn't do in your environment is setting this depth to one. And the reason I'm setting this to one is because we don't want to wait a lot here for the download of everything. So I'm going to get the latest version. Case matters here. Yeah, so you wouldn't actually do the depth one here. Okay, so the first thing we run into is that in this minimal installation we don't even have git. So the first thing we're going to install is git. So we're going to go to APT install, git will install git and I confirm and we wait for it to install it. It's not going to be long. And git of course is the source control tool that we use in the kernel. So now that we have git, let's try to clone the repo. It's downloading. While we wait for this download, there's another repo that we're going to need, which is the busy box one. So we may want to just create, let me increase the font size, you need to increase the font size. So let's do the same thing here. Depth one mirror busy box. Let's try this out. Yeah. Okay, so we're not we're also calling busy boxes much smaller and it's already done. Let's go back to the kernel. Okay, so we have both now in source we have Linux and busy box. And if we go into Linux we get the Linux source code here. And the first thing we want to do when we have the kernel source code is, and before we can build it is to configure it. Right. So one thing that that we did do as part of this project is we created this minimal configuration that you can use to just run the kernel with with QMU and busy box. So that's, that's what we're going to try to do. But, and since, oh, the reason we want to do it this way is because we want, we don't want to take a lot of time to review the current which time we need to do it and we don't want to take a lot of time. Booting, when we want to test things out. So this is a very good setup for you to relatively quickly iterate over your, your, your changes and during your development cycle. So, the way to configure the kernel is this you do a make and you do all no config. And then we have this QMU that busy box, that mean, not config, right, but as we try to do that, a bunch of things are going to fail and we're going to install the packages as we go and I'm not, I'm trying to avoid giving like a list of packages and things that you have to install ahead of time. So I'm trying to show you how you would discover that you need these things. Okay, so, so let's try that so the first thing it complains is that it cannot find flex. Right. So let's, let's install flex. And it's a small package so it won't be long. Okay, so it came back flex is installed. So let's, let's try again to the minimal thing. Now it's complaining that it cannot find bison. Let's install that. Somebody's I think asking the reference to commands so what I can do is I'm kind of following along with some I can cut and paste commands for you in the chat. Yeah, I think people want to follow along. Give me just a minute. I will cut and paste starting from the beginning of cloning Linux. If you want flex and install I already have all of that on my system I won't be running them but I will, I will cut and paste those comments as well. Yeah, thank you. Thank you. Should I wait for a bit before so you can paste the things just go ahead Joe go ahead keep going I will I will keep cutting and pasting. Yeah, please go ahead. Oh, thanks for all right so bison it's complaining about bison so so let's install that. Also as my package, it's not going to take long for this to to install okay so now we have these two. Let's try to configure the kernel. And now this time it succeeded, which is good. Now, another thing that I should say before before I show you the next step is that the, the rust compiler to change uses LLVM. So what we want to do is we want to to compile the kernel with LLVM. So, the way we do it is we had this set this LLVM equals to one option in what we do make. Right. So, here it's complaining that we don't have clan, because when we switch to LLVM we switch the C compiler as well from just to see to plan. So let's let's install plan plan is is bigger. We're installing clang but clang is not going to be enough. We're going to have to install LLVM itself. So we're going to do that. Next. In fact, while while it's while clang is installing one thing we can do is we can. So the way we can come to to to busy box because busy box just uses GCC so so we don't need to to wait for for for clang to actually it's finished so that's installed LLVM as well. Yeah, so so let's not do the busy box thing now because clang and LLVM are already installed. So let's let's let's run make again. So config to a new busy box LLVM set to one. Now it's complaining about the link and missing LLVM. Funny enough we actually got a question on the mailing list about this very air and and then so of course is to just install LLVM that's one way out of it. So let's install it. Also a small package clang I think was the biggest one. For this. Once again. Yeah so so we've succeeded okay so so now we have the kernel configured and now we could. It's compiled a kernel. However, if we just compile the kernel now it's it's not going to have rust enabled. What we need to do here is is there is there is another conflict that we can we can append here which is rust config. But if we try to do that. It runs. And it, it doesn't complain but if we look at it at the, the dot config file which is the, the, the final configuration that we have. It doesn't really have rust let me actually we don't need to run this again let's just try to compile the thing let's see how it goes. I'm going to do the J8 to compile with eight CPUs. Let's see if I have eight CPUs on this yes I have eight CPUs on this VM. So it started compiling and the, the rest code actually runs here at the top and we see that that rust didn't run so we didn't manage to to enable rust by by just running that comment. And the reasons because we don't have rust installed. Actually, not just rest we don't have a bunch of things installed. Now one thing that helps us there is this. Is this target rest available. So if you run this make, so on the rest available it's going to look at all the dependencies all the things that you need to have installed before you can, you can compile with the rest. And the first thing it complains about this is rusty right so rusty is the rest compiler. It's not, it's not here this is a trash installation. So what we're going to do is I'm going to open the browser here just real quick. And I'm going I'm going to look for rusty installation and have to accept. And I'm looking for this command line. I'm going to copy it and basically so the reason we're doing this is because we actually needs one of the, not not the very latest version but we need a very fairly recent version so if we just install rust from the from the start going to be new enough or recent enough. So we're going to go through the shot you have. Yes. One question that's and I'm following along. I did, I typed make LLVM equal to one all no config with the QMU option I am seeing I installed LLVM and client which I don't have right now I just installed them. It's saying LD dot LLD not found. Yes, so so if you scroll up you have to install another package called LLV. Okay, I guess okay I'll continue. Yes. So here's this is the area you're seeing right. Yes, yes, yes. Okay, so yeah, okay, I'll follow along and I'll put the same command in the chat. For people. Okay. Thanks. Thanks. So, so I copied the command and the thing we're saying was that we need this this more recent version of the compiler. Now what we want to do eventually is, is find a version that is that is that has all the features that we need and it doesn't need any nightly features. So let's mark that as as the minimum version for for rust, and then our expectations that eventually this will become available in distribution so you can just use APT install for example to to install that. And even if it's not the, the, the rust see official packet it could be something like rust see for the Linux kernel or something like that. Anyway, let's let's let's install this for now and trying to run curl it fails because it says that curl is not installed. So let's install curl, which is also a small package. Take a lot of time. And let's try again. The rest compiler. And I'll just proceed with the default installation. And it's installing some, some extra stuff. And it is, is, is a linter. If we have time in the end I'll show you a run of. Hey everyone. I think that what's in might have gotten frozen. So, if you can just give us a minute and we will troubleshoot and get him back. Sorry folks. A machine froze up it's it's a new machine. So I had to restart it. Let me get back to the, to the VM here. So, people are saying that they can't cut in the copy from the chat can this on the participants cannot copy in the comments from the chat. Yeah, I'm going to try to change a setting and zoom and see if that will fix it. And if not, we can definitely. We can save this chat and we can post it on the webinar page with all the commands so that we can make that document available but let me go ahead and try changing the setting and we will see if that works. Okay, if not, I don't know if people can cut in piece from the quite Q&A so we'll, we'll figure something out everybody in just a minute. Can you see the VM back. I hope you can. Yes, we can. Let's see if Rust C is installed. Let me run the command again. Okay, so the, can you put the URL for that. Yes. Okay. If you can just do that on the chat and the chat that would be great. Maybe see how it can. Okay, I can, I can do that don't worry about it. You continue and then I'll get that. I have the chat up now here so it's okay. Oh, okay, I see it. I see it. Okay, thank you. Thank you. If it's if it's if you type in it and pasting a choice not working out I can, I can probably paste the comments here to myself. Okay, let's see. Well, I am I am able to paste them. I think people are unable to copy for as. So that is the problem. Okay, so. So I think we're in some bad state here. See, see if this is okay. So let's, let's do let's do the make LLVM equals to one was available again. Let's see what what it says it's complaining that we don't have by Jen. So one thing that I do. So this documentation rust and there's a quick start quick start guide. And what I usually do is, is I come to this guide and I search for by Jen, and then there's a comment that we can run. Here it is to install by Jen. Let's see if, if, yeah, there's, there's another comment that I was going to show later but I'm going to do it now because since it's it's it's got this override one. So this will actually force rust to to download the version that we want in the kernel. So at the moment one dot 64 I think it's the latest and we use one dot 62. Yeah. So this one is is is saying that we will use one dot 62 for this directory. Okay, so again it's installing things and this is where we locked up last time. Hopefully it's not going to to happen again. Okay, so now it says it's installed. Let's see how things are things are better now. So let's let's try to run the. So, if, if, if we hasn't had to do this before what would have happened is when we ran. It would complain it would say oh you have 64 and we did 62. So we're going to into the to the quick guide quick start guide and switch. Anyway, let's let's run again the, I will actually paste stuff. So anyway, let's let's, let's do again. Yeah, there you go. So now it's it's fetching and it's going to fetch a bunch of a bunch of things here. So maybe it's a good time while it's fetching for us to to go to busy box will actually. Yeah, that's. So busy box actually has some something very very similar to the kernel it has a configuration. And what we can do is we can just use the default configuration. We make that config and this this uses the default configuration. There is there's one thing that we want to do. Let's take a quick look at my job. One thing that we want to do is we want to compile the, the busy box binary statically. Okay, so, we're going to go into menu config make menu config for busy box. So we're going to look for the go into settings. And then here we're going to search for an option that lets us compile binary here so build options build static binary. So with this we want we won't need to to add a live see to our to our image. So we've configured busy box. Let's let's build it. So now we have, we have both busy box and being built in engine budget engine came available so let's, let's now run the command again. And I was complaining that you cannot find call the source for core, right. So we're going to go back into the quick start guide. And there's a command there, this command rest up component add rest source to install the core source code for the dot 62 version, and it's installed already. So let's now try to run rest available now. It says rest is available. So what we can do now is we can try to run our all no config. And we're going to say QMU busy box. main config and we're going to do rust rest config as well. So now we're again doing that minimal configuration with the rest enabled. And now it says that there's a new value for config rust, which is why. So now rust is configured. So now. Actually, let's take a quick look at the dot config. This is available. This is the thing you should do now you do it with J8. Now should compile the whole kernel and we should have. We should have rust enabled. Now we already got some some errors, and this complaining about G elf. So we're missing a package. That. And in fact, this, this stack here, this one and bison and flags and all those things we would have to do it, regardless of rust copy this one. Because I think this one. Well already has to. Anyway, so let's let's try one more time. And I think this this time we should have everything we need. So now we see that rusty is is is is compiling core code at all. And this is going to take a few minutes. So why, why all this business building. I'd like to go back to to busy box orbit. What we did with busy box was we did a default configuration with it, then we went into menu config and we changed the settings to so that it's compiled, set it. And we just compiled the whole thing now so so we have busy box compiled. The next thing we're going to do is we're going to run, make install, which is basically going to create a directory called underscore install. For us, which is, which is our image so this is the image that we want to run our, our kernel with once the kernel completes installation compilation. Let's see there's a question here. Too hard to follow up I did not make it. Okay. So what's what's onto and what part of what part did you miss it was it on the kernel side or was it on the on the busy box side. I think, I think you're muted if you're trying to say something. Okay, while we wait for you. Let's come back, let's come back to to to busy box. So this is the image we want, we want to run. Well, not the image to the other files that are going to make up the image that that we want to. So, I got the answer from from one to one. So I'm going to stop this, but this is the command you make LLVM dash j eight, because I have eight cores. Yeah, so until and for there was a command before this one the rest up override. If you look up there's a rust override set and some some stuff after that. That's so you need to run those commands so that you switch to the, to the 62 version of the kernel. Yeah. I'll continue here. Again on continue the kernel where it's left off. Yes, this is being recorded there'll be a it will be made available later. So, the tool we use to, to, to build the image that that that we, we want is CPIO right so what you do with CPIO user feed it a list of files and it creates a CPIO image out of that. So what we're going to do is going to find out which just gets a list of files under the current record and we're going to do CPIO. And this specifies the, the format that that we want to, to, to create the CPIO with. And we're going to do dash oh, and this actually writes to to as to the out so we're going to redirect it to run this image. Yeah, so run this way. Well actually another thing that we want to do is we want to compress it to pipe it to jizz it as well. Copy this command. There are a couple of questions here in the chat as well as Q&A box. Do you want me to read them out or you can you see them. If you could read them out I'm trying to not otherwise they get too distracted looking at. That's fine. I'll read the one out in the question and answer box does the kernel require a specific Rust version or a minimum Rust version. So, at the moment it requires a, well it requires a minimum version but if you use a newer version, then it may not work right so use it at your own risk right so the idea is that if you go below that then it's unlikely to work if you go above it will probably work but we can't guarantee the exact version then then then it will work. So we suggest that people just use the 62 version. And then what we do is as new versions come out and fewer and fewer unstable features are used because they're stabilized then we we upgrade this this version to the latest. And as I said eventually we want to stick to one. We're not there yet. So it would be, it would be wise to run rust up and then make sure it's not matched. Yes, exactly. Yes, that's that's our recommendation. That's great. Thank you. And there is another question. Is there any module currently running in the new kernel release, which is written in Rust. So we cannot really understand that question. There isn't no new kernel release with rust yet. The six step one is the first one that will include some rust minimal path set for rust. Maybe you can go into more detail on that. Yes, but what you said is exactly it right so the latest kind of version this is six dot zero, and there is no support there. Now, we expect it to be to be released the final version to be released on Sunday, and then the merger window opens for six dot one, and our expectation is that rust support will be merged then. All right, so when the first RC of six dot one comes out. That's the first time you're going to have rust support, but that's minimal patch series that that that goes in so it's just add support. It doesn't add any drivers or doesn't add a lot of abstractions. Just yet, those will come later. So what we're going to do next after this this part is merged is we're going to go through the, the maintainers of different subsystems and work with them to merge all the important abstractions for those subsystems for which the maintainers. They will, of course, and then only then should be expected to see actual drivers being being written and released in rust so it's going to take a bit before we get there. So is there anything else or was that was that. No, that that's it for now it's and I will ask. I'll pin you if you there is something going on. Okay, thank you. Yeah, thank you. Thanks. So, so now with this we actually have a red disk. The image here that we can use to put our kernel and we've actually managed to successfully successfully build the kernel. So the next is we want to run it but we don't have to install it. So let's, let's install it. Let's this package called QMU KVM dash KVM that install it will give us a QMU virtual machine manager that will allow us to to run the kernel that we built in AVM. There you go so it's installed so so this is this is how this is the name of the of the binary. No graphic. Just want to get console on it. And we're going to run the kernel we just built. Okay, so if we just do this, then you can see that the kernel actually runs. And this is the one that that we just built. But it fails to do anything useful because we don't have user space. So we're going to come out of it. Control AX comes out of it. I'm going to do reset here to reset the console. So I can get line breaking back. And then what we can do is we can add this in ETRT to specify that busy box image that that we compiled in this other window here. And that's this rendis club image. All right, so if we if we run it this way then we don't have that that error here anymore we have this periodic complaints here. But if you see we do actually have a prompt in which we can we can type commands. Like PS doesn't work. It's complaining that it doesn't see a profile system yet. But the first thing we want to do is actually make this go away. So let's stop this. And let's come to the image. And so what we're going to do now is you're going to make some changes to this image. And these actually are not even rusty specific they this source of changes you actually want to do if you if you're trying just regular kernel anyway. So, the first thing we're going to do is we're going to we're going to copy there's this like in examples there's there's a neat tab. There so that's creating me to see directory in here, and let's copy the one they need to have from from examples. Let's go to ETC. And let's modify it. And what we're going to do with this file is we're going to, if you scroll down there's there's this other city wise here two to five so we're just going to remove them. Let's just remove them. And then we run CP IO again on this directory to regenerate the image. So, if we now now that we've regenerate the image if we come back to the kernel and we try to to run it. We actually get the console and we don't get that periodic, those periodic messages complaining that those city wise we're not available. We still have these complaints that it can't find this file and this file is interesting for us because it will allow us to run things as as we do. So we're going to go there in a second. But before we go there, let me show you one problem that we have if we try to do PS for example complain steps that it can't find prox so what we're going to do is we're going to create prox. If we just create prox, it's empty right there's nothing in there. So we're going to mount a prox file system there. So with this amount of going to prox now we actually have it popular and we have all the processes here, which actually allows PS to work so if you do PS now we can see the processes and kernel threads running. In this instance of the kernel that's that we are using at the moment. So let's. So what we want to do is when we boot we want this to be available. So we're going to create that file if we scroll up let's get the name of the file and directory so we're going to create this file in in this file we're going to mount prox automatically. Let's come out of here. Let's go back to the, to the busy box installation directory. Let's create this, let's create this, this, this directory. Let's edit file in there. And great directory. And the type of file system is is prox. There's we say none for the debt there's no there's no device. And we don't put prox. Yeah, I think that's, that's what we want. I'm thinking about. I've opened the wrong one. Open the one under this yes. Good again. So this creates a directory and then we will mount the prox file system on top of that directory with no devices. Why is it not allowing you to do that. What to see. Oh, because when I did a make I also did the make with the slash in the front so I created in my local directory in my local file system, rather than this one so okay. All right, so now. Now it should work. All right, now now it works. So let's look at it. Okay. Let's run CPIO again to regenerate the image. And let's let's run the kernel. Oh, now it's complaining that we don't have permission to run the thing so we need to to make it execute executable to see so we do the CH mod. Yes. Let's run CPIO again. So now we can boot and we can run PS because proc is mounted in fact power off also also works it complains about some stuff but but it comes out of this. Now. So now we have a minimal image which which works minimally with PS and so what we're going to do next is we're going to to enable one of the sample. Rust modules, and we want to to to see it working. And then we'll see that there are a few more things that we want to add like not working to this to this image to get to the state that we were in the in the in the previous session. So let's let me let's let's do this. We're going to do we're going to go to, to, to menu config. Okay, we're going to do make LLVM equals to one menu config. And, and the one that I want to enable is like we're going to kind of hacking. Which is, which is less on actually, instead, instead of, instead of going there, what we're going to do is we're going to go search. The rust echo server. Yes. So, if we are here in menu config and we press slash. It allows us to do to do a search so we can do a search for rust echo server. We find it here and there's this one other set if we push one, it'll take us there so push one. It doesn't take me right there because simple kind of code is disabled so if we enable it first, then we can go into it, we can enable rust samples, and we go into it. And now we have a bunch of samples here is one of them is this echo server. And so I'm going to enable this echo server and then I'm going to exit. I'm going to save the configuration. So if I build the kernel again, do dash j eight. Then of course I don't have to rebuild the whole thing. Because I've already built it once. But it's going to include now the, the echo server thing that I've just enabled. And now it's linking that the rest of the kernel. One thing that that we want to do is because this this server actually doesn't print anything to the screen so let's add a print to to that sample. So we can see something on the screen once we, once we boot. So so I open this file and I'm going to do a PR info. Hello from echo server was so isn't if. So this is, this is what we've added. Let's see if it's as if it's recompiling the, the echo server. And let's try to boot this now. And after booting we actually have rust echo server hello from from echo server. If we do that stat can see that we are listening on so what this echo server does is it listens on port 8080, and it's just an echo server if you connect to it and you send some text to it it will send you the text back that's that's that's all it does. Now, if we try to connect to it it's it's it's it's not going to work to see it just failed and the reasons because we don't have any interfaces up. If you do I have config it's, it's, there's nothing there. So if we enable look back at least then look back shows up which is good. Then we can connect to the to the echo server. And there you go so if we send. Hello, it sends hello back testing, passing back, we can disconnect. So, one, one thing that we'd like to do is to have the interfaces automatically up on on on on the VN, once, once we boot so we probably want to copy that this is I have config low up. Come to our image and modify it, such that we can automatically get look back and then we rerun CPIO. And this I'm doing manually but one thing that you can do is you can write scripts to automate this for you every time you change this and you rebuild the image. So anyway so another thing that that we want to do actually let's let's let's try that out first let's do a power off. And let's rerun the VM. And let's see if. Yes, so we have look back there so if we try to connect. It should work now there you go, I can send messages, and it will respond. This this actually enabled look back and they can they can connect and within within the same VM but I can talk to the outside world and the outside world cannot talk to this VM. So one thing that we want to, to enable is is is an actual. Nick, and that's working to face card to this. Yeah. So one thing that that we can do is we can do Nick to the QMU command line. And you can say, usually we want to run a user mode. Network in emulation on on on QMU and the Nick that we're going to show inside inside the VM is this RTL 8139. If this works. If I do I have config I still just get the look back. But if I do IP link, I see that I have the eth0 here. So one thing that's that we can do that that comes with with busy boxes this. And you can say, in the face zero. The HCP the interface. Is it not working. Oh, it's clients. Yes, there you go. So, with this we. We get the we get the we get the the the the HP to to run that's complaining that some something is down. But the thing is some of the configuration stuff actually needs a script so we need to we need to go to our image here and and we need to create a directory. Let me see it's it's user share you the ACPC. And you're going to copy from examples again, you the ACP simple script is let's call them. Share. And let me see here I have a script. Let's do a cat to make sure we have the right file in the script. Yeah, so I just copied a script from one of the examples in busy box into into this directory. And we're going to, we're going to update our. Our next script to So automatically run that. Let's try that let's see if this works. Let's rerun our, our VM. And now with that script enabled we actually get it h0 working, which means that we can we can do something like that you get, for example, right so we actually have that working in this in this system. So let's remove this this file we just downloaded. So this actually allows us to go from from from the VM to to the outside world. That's the next thing that I want to add here is the ability for us to tell that into this VM so we can actually have several more than one session at a time if we need to, if you need for example to run a command and while it's doing we need to run another command. You may want to have this telnet D running on the on your on your VM so you can interact with it from several different things. So, we actually have to, to, to, to add an entry here to the QMU command line that forward sports. Okay. So we're going to do something like host, post forward TCP and I'm going to say I'm going to forward any address from the VM. Any address on the on the host to any address on the on the VM ports 23. Okay. There's another thing that we need to do. We need to to get Dev and that pts working so let's let's let's try that. PFS that so our dev now is populated. But we also need pts. So if we do this we can run telnet D. Okay, so tell that the is is running on the on the VM. So let's come out and let's tell that in support 5555. And now we are in the VM. Right. So we actually at the moment have to terminals open on the on the VM one is is is the console itself from from QMU. And the other one is is via telnet and disconnect and you can connect again and we can do things like this. In fact, we can, for example, kill the other one. And, and, and, well, it didn't kill it. Let's try with dash nine. Yes, so now that the other console was killed and if I press enter a new one that's created. So what would you name show in that shell. You name that show. Okay, so that's the one that you just built and our system call. Thank you. Yeah. Yeah, this is the one that I just built. Yeah. So let me tell that into into that. Yeah, so so so with this we actually have a we have we're allowed to actually connect to the to the to the VM. And so perhaps what we should do is we should do that all automatically so let's let's go again to and and and that those commands. This quickly. The one that yes. Yes. Let's see I'm not sure if there are no pipe was there but power off the VM. I actually need to make let's just run QMU again. Yes. Yes. These seems to be running. Let's try to tell that again. Yeah, so now now we get we get talent. Just by building we don't actually need to power off. So this. So when we powered off it, we just lost the connection that we had. And this other one came out. Yeah. Another thing that we can do is we can we let's let's forward copy this command and then forward the the other port to 5556 80 port, which is our echo server running here. And I'm going to use NC 5556 to see like the echo server that we had running inside the VM we can connect to it from from from the outside now. And in fact, if we do if you do and that's that we can see that there's a connection. So we have the we have the listening sockets on on 48080 and we have established connection, which is the one coming from from the host into into the VN. And of course we have rust code there, accepting these connections and sending this this a little messages back. So another thing that I wanted to show you is is rust analyzer. Let me let me stop this. Let me come out of of of the VM here. So the idea here now is that we have we have a an image and we have everything set up so that we can compile the kernel and we have to be installed and we can we can run the kernel that we have installed. We can it has rust enabled as we as we showed with the PR info that we added to that sample. We can interact with the outside world of the outside world can interact with us by via via these forwarded ports. So one thing that I'd like to show now is is this rust rust analyzer thing that is very easy to look at the code while while you develop it. Yes, but before you we switch gears are three questions in the question and Q&A box. I can start reading them to you when you are ready. Yeah, yeah. The first one is is rust support being added only for drivers or is there a future goal to write non driver parts as well in rust. So the, the support that is being added now we support to compile code into the kernel, right there are no restrictions as to what it is that that that one is writing. Right. However, we're still in this stage where we only can only use rust C, which is based on LLVN which doesn't support all the architectures. Yes, there are other projects that will allow us to compile and use the GCC back end. So we'll have access to to eventually we'll have access to all the architectures. So at the moment, we're saying that we're recommending that people only write drivers for for leaf nodes that you know wouldn't necessarily be needed in all architectures yet because of these limitations, but it's it's just mostly an architecture and support for subsystems thing will get there eventually. Thank you. The second question is, can we also use a busy box container to boot the compiled kernel from busy box container. Not sure what what is meant by a busy box container. But what we're doing with busy boxes is we're just creating an image and we're using that image to boot the kernel. And if if if someone has some other image, then they can just use it. In fact, so this is just for quick prototyping so it's this is the busy box thing that I set up that I'm showing here. It's just for you like you're changing your code very quickly and you want to to run it and see what the results are. And what what one needs to do is actually put a system configured with potential with default configuration and both like a real distribution, right, like Ubuntu you can actually compile the whole kernel and then with Rust enabled and that thanks to it and just just put regular Ubuntu or what have you. So I don't, I don't quite follow the question but if you could, if you want to clarify and I can try again. While they come back with the clarification, there is the third question or the configuration steps, which you did for building configuring busy box also documented in the grid project. I couldn't paste to the quick start document in the chat so I think this might be a follow on question that are these steps that you just did in this session. Yeah, I don't think the step to do the QMU busy box image thing is documented well actually so. There is there is like if you look at if you go into kernel configs. So we actually say it's a minimal configuration blah blah blah we specify how how it's it's run, you know, and in fact we even have the command line for running QMU with it on both actually six and they are 64. What we have, what we don't have is a link from the rust documentation to this, because in fact this is not rust specific you can you can you can do all this part, independent of rust. Right, this is for anything any kernel image not specific to rust, which makes it handy for people to start working. Actually, people don't have hardware support and they just want to do much hardware with them. And to use. So, yes, thank you, but I think that's all we have right now. In the box and chat as well. Yeah, thanks. Thanks, thanks for. Yeah, if the person who asked the question comes back I can try to clarify there. So yeah so so the thing I wanted to show. A lot of time, so I'm not gonna show a lot but so we have this thing and I think I sort of mentioned this last time. We have we have this this this target that is rust analyzer. And that's, if you run it, it creates this this file called rust project.json, which is configuration for the rust analyzer LSP language server protocol. So, let me do this come to the browser and I'm going to, I'm going to install visual studio code and what I use really is is the OVM but the configuration of press analyzer that is complicated have to copy and paste a bunch of things from different places so I'm not going to show that I'm going to show the visual studio which is actually much much simpler to install them. I just want to showcase what sort of sorts of things you get. Once, once you have it. So I came to this. To this page and I downloaded visual studio code. And so I'm just going to install it. And once once we have it installed, I'm going to open it and I'm going to install the rest analyzer extension, which you can do directly from from visual studio code. And then we can use the code. So I can so so this is visual studio code they can come to extensions. And if I type rust analyzer here. I can install. So, so visual studio code is just an ID you can you can use it for several languages and if you want to use it for rust you can install this thing. Then I can come to open folder. I'm going to go to source Linux. I'm going to say open it. So here, here we have source code we can go into. So if we open the file dot RS in our in our source code. And like you have lots of comments and lots of lots of code here but one thing that that's that we can do once once rest analyzer is running I don't know if rest analyzer is actually the code yet let's see if I can jump to the definitions and things like those. No, it's not showing me maybe it's not. Let me look at, we look at the extensions again is it. It's called us. Let's run the target here. Let's make sure that we have. Right. Okay, I go it's asking if I trust it and I'm going to say that I do. So let's open that for the now I think it's, it's, it's going to work. It's come to file to if we can. Oh yeah so so now we have a lot of a lot more options here but, but the idea is so for example let's let's I'm here in committee and I have this a wrap object. I can cover over it. I get to the documentation right so it says it's coming from kernel types. It says it's destruct and T is always recounted and there's a description here are some invariance. And if I right click I can go to definition, and that text that it was showing that marked up is actually coming from from this text here right so one thing that that we're trying to enforce is that all public. Items structs functions, anything should should have documentation in it right. And then, when you have rose analyzer installed, then you get this this sorts of helpful hints of descriptions and you have you have completions to so. Yeah, you can do something like, you can do file dots, and then we, we get a bunch of options here right so it's a reference counted things things so we can clone for example to to to increment the reference we can also D rap to get to the to the in the file and then have a bunch of other things. So this is this is one thing that I wanted to show was just that this tooling around rust allows us to get better experiences. I wouldn't say better necessarily but I don't know more options when when you're editing source code in comparison to to rust. So we can, we can, we can go to references of something for example very, very easily and this box shows us, and this actually works on on any ID that tests or any editor that has support for LSP right so in my case I use new beam so it's all text. It's not graphics like this. So so let me close this. And let's come back here so before before people send pull requests. One thing that I should let them know is that we have some CI that runs a bunch of tests automatically and and that's just some commands automatically for you. So this is like a sort of sorts of things that you want to do ahead of time to make sure that your your PR is not going to be rejected right off the bat. The first thing is formatting. We run this format check, and you see like it already failed it's it's it's complaining that it's not properly aligned. So you can either manually go there and fix it or you can remove the check. And just ask it for it to format it for you right and then if I do a gift, then it's not misaligned again so if I run the check now. And succeeds. Okay. Now, another thing that that we do is we generate documentation for you automatically from from the source code. And one thing that this rust doc catches for me at least when I'm developing things is when we are writing documentation sometimes we cross reference other other types of the functions other items in general, or modules whatever. And then if you actually make mistakes in these references, this rust doc will find them and complain about them. It's good for you to run them before you submit a full request because if you have errors like that, you'll catch it later earlier. Now, another thing that is very nice about running rust doc is that if after running it you look at rust and doc directory you actually have HTML documentation all their format it. For example, if we open this one, this is this is the sort of thing that that we get automatically generated for us right. It sets the candle crate and it has a bunch of modules inside it so if we go to networking for example. Then you have all the structs decide defined insights networking and the denoms. So if you go into the before address. And shows us the public parts of the definition of it before address. It shows me the methods that it has. And all the items like method is new and some constants inside it broadcast look back any. And in fact you can go to the source code, you can click here. And it'll show you the formatted source code that from which this thing was was was extracted. So, if you want to browse your latest version of documentation you can run that rust doc. And you can go into the rust doc directory, and you'll find everything that that that was generated from from your source source code from your tree. Another thing that we have is we can run with clippy equals to one, which is a linter. So this is also something that that we run in the in the CI and if the linter catches anything we're going to fail for requests so it's it's good for you to run this. And there are sorts of things that this this fine. Well, it finds occasionally finds things in code that I'm writing, but the, a lot of the things that it finds for me are things where I write some complicated expression or convoluted way of doing something. And it actually shows me a simple way of doing things. So this is actually quite quite helpful running running to be that the moment it didn't have any, any, any complaints. So another thing that we do is rust test, which which runs on the host, some tests that are independent of independent of kernel code, right. And this is also something that we run the CI so it's something that you want to to run automatically. And if you write code that doesn't depend on any of the kernel functionality, then we encourage you to actually write tests. And this test will run on the host, like, like here. Now, once this is done, I'll show you another thing which is that we also run some tests that depend on kernel code and we use K, K unit for that. At the moment we only support code coming from documentation but eventually will will support other types of tests. So while, while, let's let's wait for this. Well, actually, well, go ahead. I have a quick, quick question. I have been. So do you have what happens when you look at the documentation for samples for example echo server. Does it automatically generate some documentation and show us what it does the source file itself didn't have any information on what it does. So it's just curious on. And no, I don't think that's because the documentation is for public things. Right. So, the, the, the rust like a server for example I don't think it would even appear that because there's nothing public in it. It's not just a driver doesn't expose any interfaces to the outside world. So, yeah, that that wouldn't appear. So one thing I noticed is I was looking at the rest for Linux get the other day and then I was looking to see what exists and samples and to see one thing I noticed is the documentation on the samples is somewhat minimalistic. So, so it might be, it might be good to improve the documentation or you can have people send you documentation of course that's the best way to learn right. Yes, yes. So, so that you're right. Can we agree with you that the competition that is for there's another thing that makes it even worse is that the code that we have in samples. It serves two functions one is it's simple but it's also testing right so there's some that it's not very clear because we're trying to test some corner cases of things and so they're not really samples in some cases you know, and people may get the wrong impression by looking at them it's like oh this is so complicated why why would anyone want to want to write this. So I agree we need we should probably move some of the tests out and improve the documentation on the actual samples. So the echo server is a sample and it's it's it's quite small and I'll take that feedback and I'll work on improving the documentation. Yeah, absolutely you have you're busy with the more important things like how to get it get the rest integrated into kernel I get that definitely so this is just something I've observed as people. So this will become important as people. Once it gets into RC one and people start looking at it and saying, okay, how can we get involved. Right. How can we start writing code and such stuff. Yes, yes. Yes, having having samples and probably documented will help people starting. Yes, I agree. And what you're doing now is great because this is what this is very timely for the next and then we can just point to them and say, Hey, look at that sense webinar. Yes, yes, it worked out right by chance but yeah, I think it was a good timing. Yeah. Okay, so. Are there any other questions. I'm good for now I don't see any questions either in chat or Q&A box. Okay, so I'll show quickly. We only have nine minutes. We're good. So, the thing I want to show is K units. Okay, so. Let's enable it so by default it's it's disabled. But if you go into menu config. And search for K unit. And you enable it. Now we have rust kernel. Yeah, that's that's what it's called so that's enabled. So, the first thing we did here was we enabled K unit itself, which any kernel component can can and should use. And now we're enabling K unit for for the kernel crates of the rust source code. Now, if we save everything and we compile the kernel again. Oh, one thing that we may not have time for this but we don't have to recompile the whole thing but anyway so let's so we've enabled it and let's let's let's run it. Let's let's recompile it if if it finishes in time we can we can show you something if it doesn't it's okay I'll just talk about it so. So here's one thing that we do let's let me while it compiles in this window let me show you in this other window that the sort of thing that we have that is cool. Let's see if we can find our queue. Yeah, I think what curious is this is a good one. Now, if you look at the at the, actually, you know what I'm going to I'm going to show this in in Visual Studio code because it's it's better formatted. So let me. Let me show you this so if we come here was I was working so if we're going to some of these modules. And so I think this goes a little bit towards what you're asking about better documentation in the samples. So here's here's here's one thing that is. Interesting that that we have in in Rust let me scroll down. Yeah, so so. So here here we have we have a definition of of of work use. It's lots of samples of a queue right so if I, if I hover over it and I, and I come to the examples. Right. You can see like I have like the following example is a simplest way to launch work item and then there's one line that shows you how to launch a work item. But there's some allocation involved, but there's another sample down down here that shows you how to do it in the with a sort of C style where you embed something into the into some auto struct, and then you get to run. And if you see like we have documentation that says what the, what the, the, this queues up here it wraps the work queue struck from the seaside and blah, blah, blah, but we have these samples as well. Now, the part that I wanted to show which is linked to pay unit is that what we do is we actually get this code. And we compile it into the kernel when pay unit is enabled and we run it as a text in in the kernel when when we boot it. And this allows us so this actually shows people writing codes. How to actually use these things. And it also shows you complete examples that we know that won't rot because every time we compile the pay unit enabled we compile them and we run them and make sure that whatever we test inside actually passes. So, let me go back to the, to the console. Yeah, I don't think that we only have five minutes left so I don't think we'll have time to show this but what what. So this finishes if you run QMU just regular QMU you'll see as as it puts towards the end you'll see KK units running all the tests and if, and in the end it gives you a summary of the result. And if there are failures of course you you get to see and you should go try to figure out what the problem is. But, so I'll stop here because we only have five minutes I'll go back to the slides. There was just one thing that I wanted to say that. And then if there are questions we can. There is one question but yes, I, you can switch back to slides and then drop up and then we can ask to the question. Yeah. Yeah, so the last thing I wanted to say was that we actually have another session coming up. Next month, and I'm going to, to show how to write async rust code in the kernel. So that's the echo server is an example there's an IP server that I talked about in the in Congress was this rust for Linux workshop that we had a few weeks back. And we're going to show you how to write async code and the idea there is to is to show how you can write code that is like straight line code and that looks like you're burning a thread but it's not really running burning a thread it's running it in. In a single thread of your choosing, or if it's running, it's running the work queues managed by the current and they're available on the, on the seaside. So, thank you very much. This is all ahead. So I, there are questions. Yes, there is one in the Q&A. What about rust and kernel cross compilation. Let's say for arm architecture. Is there any specific hint regarding cross compiler or two chains. So, we support cross compilation. And in fact, I've, my primary environment for testing was AR64 before. And the, there's actually compiling rust code is actually simpler, because we don't need specific to change installed the rust C supposed to generate pretty much anything so you so you, you, you, it's, it's actually easy to do cross compilation with the rest than it is for the rest of the seaside. And that is supported. We only have a subset of architecture supported, but those that are supported support cross, cross compilation. It's actually simpler. Okay. Anything about GCC rust project. Can you be more specific, we shall about the question. I don't know that I understand what you're asking, unless Watson, the question is clear to you. Yes, I know what what they're talking about. So GCC RS. It has been approved by the GCC steering committee in the next GCC release there will be like a alpha beta version of the thing it's not ready. If you actually go to the videos for Linux plumbers. A couple of weeks ago. There is actually a talk there. So, in plumbers we actually had a micro conference for rust. And we actually had the folks involved in GCC RS, give us a presentation, which was very cool they can they can you can you should I recommend that you watch those. If you listen to that there's another project, whose author also presented at plumbers in a different session of just using rust seed self as the front end but using GCC, this is his back end to generate the code. And that project is a little bit farther out. And in fact, he entity is the person that he can actually build rust for Linux with a few hacks, but he can build it and he can boots the kernel. It's a bit hacking but it's getting there. So both both project both projects are very exciting and we look forward to seeing them come to to final state. Next year so cool. That's all we have questions twice. Okay, that's all I had to so. Looks like there is one more that came out. I am a complete beginner to the contribution to kind of Cardinal where should I start hope the question is not. Oh, I see. Go ahead, I would say I can feel that go ahead and start taking a look at. I have several resources, events at this mentorship series, but I sense a lot of gives you a lot of opportunities and to look at what's how you can get involved. And then we also have a free coursework available on the training site. If you go look for a lefty 103 that kind of gets you bootstrapped on what how to set up your environment and then start working there. And then you can also participate on Cardinal newbies IRC channel. People are very helpful, helping beginners there. And so there are a lot of resources available to you as a Cardinal developer and then, if once you get started you could also participate in mentorship series. The last slide that red sun had in the deck gives you a lot of information on resources for new developers. Yeah, and the previous session that that I presented that doesn't really assume much in terms of knowing current development and things like that. So you could check it out to you can can follow the steps there and with those steps you can you can build a module and hello world sort of thing. Yeah, so so I think that's it so can this if you want to take over. Thank you guys thank you so much what to ensure for your time today and thank you everyone for joining us. As a reminder this recording will be on the Linux foundation d2 page later today and a copy of the presentation slides will be added to the Linux foundation website. We hope you're able to join us for future mentorship session and have a wonderful day.