-
-
Notifications
You must be signed in to change notification settings - Fork 343
Implement disk ejection #2282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement disk ejection #2282
Conversation
Signed-off-by: Benjamin Somers <benjamin.somers@imt-atlantique.fr>
|
|
Great, I’ll tidy everything up and smooth out the corners, probably tomorrow. |
For 2), we'd want to make sure we don't break live migration. That is, if we have a running VM and we eject the disk, the target VM needs to not have the disk attached when it's put together to receive the migration stream. Otherwise the hardware won't line up and migration will fail. |
I think the current logic is safe in that regard, but I’ll test. |
Signed-off-by: Benjamin Somers <benjamin.somers@imt-atlantique.fr>
Signed-off-by: Benjamin Somers <benjamin.somers@imt-atlantique.fr>
Signed-off-by: Benjamin Somers <benjamin.somers@imt-atlantique.fr>
On to testing with migration now |
A few things.
Gotta investigate a little more, although I take ideas :) Edit: for (iii), looks like |
Should be good now, pointers for (i) would be appreciated if you have any. |
I don't know what would trigger that. Depending on how early that is, maybe we can add a QMP status check of some kind to only handle eject if the VM is fully running. |
Here’s an excerpt until the
|
Oh, if it's an agent drive, then it's totally expected. Our init script ejects the drive after copying the data as we don't want the drive to be visible to unprivileged users on the system. That may actually be a slight issue there as we want that particular drive to come back on every boot. So we should actually check and only remember the ejected state if we're not dealing with one of our internal drives ( |
Oooooh good thing I didn’t have another ISO on hand, because we’d have missed that behavior. I’ll add a safeguard to the code to properly handle automatically ejected drives.
|
After having a look at it, it seems that the agent auto-ejection only happens when the device name is Edit: I can’t understand why the transactions fail; I’d really appreciate an additional pair of eyes :) |
Here, “agent drive” means “drive called
I think that in this particular case, it’s actually the drive name that matters. I’m trying to identify the code paths that handle that. EDIT: maybe we should just prevent people from creating a device named |
Signed-off-by: Benjamin Somers <benjamin.somers@imt-atlantique.fr>
Signed-off-by: Benjamin Somers <benjamin.somers@imt-atlantique.fr>
Signed-off-by: Benjamin Somers <benjamin.somers@imt-atlantique.fr>
Signed-off-by: Benjamin Somers <benjamin.somers@imt-atlantique.fr>
Actually this logic seems a bit wrong to me. Rather than relying on the device name, we should rely on some metadata in the image itself (ISO). I'm looking at making a small change to do that. We rely don't want to special case specific device names. |
By looking again at it, it seems that some of my assumptions were wrong. I think my |
@bensmrs you could use SplitN(x, 2) on it and then check that you indeed got two chunks out of that. That'd give you both the value you need and perform the prefix check in one go. |
Otherwise everything looks good in here. The other PR I sent will avoid the weird device name special casing we currently have so we should be good to go once you tweak that TrimPrefix call. |
I did a test checking if the prefix is there… and the prefix is indeed there. I’m a bit confused. (I’ll try cherry-picking your commit) |
What's special with those devices is their content, that is The rest of their handling is normal, they are not treated as internal devices, they show up as normal user defined disks (because they are) and use the name the user provided. But because they are generated at boot time and read either by the Incus agent load or by cloud-init, both of which may want to eject the drive to hide it from the system, yet have it again on next boot, we should find a way to process the eject request but NOT persist it through the device option. |
My point is, even without mounting an agent disk, if the device is called |
Ah, that's pretty odd behavior from QEMU |
I'm really not convinced that this is a QEMU issue though, the timing you're showing looks a lot like: https://github.com/lxc/incus/blob/main/internal/server/instance/drivers/agent-loader/incus-agent-setup#L50 My other PR won't fix that immediately. I'm changing the script inside of Incus, but we'll need to push it through distrobuilder too and then have that roll out to all our images before the change is actually effectively. You can try manually applying it to your |
Completely overlooked that. Seems to work! |
Ok everything works, without any need to patch the TrimPrefix side. |
This PR is not 100% ready. I’d like to discuss 2 things:
Emulating an empty tray will require a bit more work, but can look a bit fancier to the user, actually seeing that the device is here but not the blockdev.
Closes #2093