Skip to content
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

interfaces: hotplug nested vm test, updated serial-port interface #6491

Merged
merged 81 commits into from
Mar 27, 2019

Conversation

stolowski
Copy link
Contributor

@stolowski stolowski commented Feb 11, 2019

Update serial-port interface to support hotplug, and add a new spread test for nested vm to exercise hotplug subsystem using qemu's serial-port.

The test can be run manually like this:

for xenial:
spread -debug google-nested:ubuntu-16.04-64:tests/nested/classic/hotplug

for bionic:
SPREAD_NESTED_SYSTEM=bionic spread -debug google-nested:ubuntu-18.04-64:tests/nested/classic/hotplug

Thanks to Sergio for laying foundations for this test and figuring out qemu stuff!

Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

another pass

interfaces/builtin/serial_port.go Show resolved Hide resolved
@pedronis pedronis self-requested a review March 8, 2019 07:12
Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

thanks, couple comments

interfaces/builtin/serial_port.go Show resolved Hide resolved
check_slot_not_present() {
SLOT_NAME="$1"
for _ in $(seq 10); do
if ! execute_remote "snap interfaces" | MATCH ":$SLOT_NAME"; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we use "connections" now instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep! This uncovered a bug in integration between connections & hotplug - HotplugGone is not honored! Bugifx coming in separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to use snap connections, but it needs #6590 to land first.

@pedronis pedronis added this to the 2.39 milestone Mar 15, 2019
Copy link
Collaborator

@zyga zyga left a comment

Choose a reason for hiding this comment

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

Thanks for converting serial port to be hot plug friendly!

I've added a couple of comments inline. Some are clear follow-up since they require additional debug infrastructure (those that avoid the jq-inspired editing and querying of state). Some are small changes to proposed code that can be done in this branch, if that is what you want.

One thing I'm worried about is the extensive use of "try a number of times, sleeping" pattern in tests. Could we move that out of individual query routines and into a "wait-for-settle" helper or something alike? I fear this may be masking real bugs.

fi
}

DATA="$1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is data relevant to be an outside argument? I think this could work fine without that.

tests/nested/classic/hotplug/task.yaml Show resolved Hide resolved
. "$TESTSLIB/nested.sh"
create_nested_classic_vm

copy_remote "${GOHOME}"/snapd_*.deb
Copy link
Collaborator

Choose a reason for hiding this comment

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

Specifically this part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above.

return nil, nil
}

slot := hotplug.ProposedSlot{
Copy link
Collaborator

Choose a reason for hiding this comment

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

For USB devices we could also synthesise a slot label. The value could come from the ID_MODEL_FROM_DATABASE and ID_VENDOR_FROM_DATABASE attributes. The label is not used for matching but is used for display in some cases (it is also underused because it was always empty).

For example, plugging the Arduino UNO with this change would show a nice human-readable description of the slot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Logic for that already exists and is outside of this PR as a general mechanism for hotplug - see suggestedSlotName function in hotplug.go - it currently looks at "NAME", "ID_MODEL_FROM_DATABASE", "ID_MODEL" attributes as input data for slot name. That logic doesn't fill in Label and doesn't look at ID_VENDOR_FROM_DATABASE yet, but we can experiment with enhancing it and all interfaces will automatically benefit from it. I think this will be a material for separate PR. The logic here in HotplugDeviceDetected shouldn't generally bother with name/label unless an interface wants something non-standard.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1, I would love to see the follow up that uses the label more prominently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do, but we will need to think what makes sense here, as we need to populate name and label (let's not discuss here).

Copy link
Collaborator

Choose a reason for hiding this comment

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

do I understand correctly that we remember slot names? so if we change naming strategy there will be no confusion/renaming of preexisting slots?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pedronis Yes we remember their names for as long as they have connections, and they wouldn't change if we change naming strategy. The names can only change if you unplug the device and it has no connections, in such case we will forget the slot and it can get a new name next time when device is plugged again.

interfaces/builtin/serial_port.go Outdated Show resolved Hide resolved
interfaces/builtin/serial_port.go Outdated Show resolved Hide resolved
interfaces/builtin/serial_port.go Outdated Show resolved Hide resolved
interfaces/builtin/serial_port.go Outdated Show resolved Hide resolved
@stolowski stolowski merged commit fa7503a into snapcore:master Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants