Skip to content

Conversation

@rbradford
Copy link
Member

Support unplugging the same types of virtio-pci devices that we support for hotplug (disk, net and pmem)

Rather than panic()ing when we get a kernel loading error populate the
error upwards.

Signed-off-by: Rob Bradford <[email protected]>
This id will be used to unplug the device if the user has chosen an id.

Signed-off-by: Rob Bradford <[email protected]>
In order to support hotplugging there is a map of human readable device
id to PCI BDF map.

As the device id is part of the specific device configuration (e.g.
NetConfig) it is necessary to return the id through from the helper
functions that create the devices through to the functions that add
those devices to the bus. This necessitates changing a great deal of
function prototypes but otherwise has little impact.

Currently only if an id is supplied by the user as part of the device
configuration is it populated into this map. A later commit will
populate with an autogenerated name where none is supplied by the user.

Signed-off-by: Rob Bradford <[email protected]>
Add an accessor to return the underlying VirtioDevice. This is useful
for managing the removal of the device from internal datastructures when
handling virtio-pci device unplug.

Signed-off-by: Rob Bradford <[email protected]>
Extend the eject_device() method on DeviceManager to also support
virtio-pci devices being unplugged.

Signed-off-by: Rob Bradford <[email protected]>
If the id has not been provided by the user generate an incrementing id.

Signed-off-by: Rob Bradford <[email protected]>
We now support assigning device ids for VFIO and virtio-pci devices so
this error can be generalised.

Signed-off-by: Rob Bradford <[email protected]>
This ensures that a device that is removed will not reappear after a
reboot.

Signed-off-by: Rob Bradford <[email protected]>
Ensure that the device is removed and the removed device stays away
after a reboot.

Signed-off-by: Rob Bradford <[email protected]>
Ensure that the device is removed and the removed device stays away
after a reboot.

Signed-off-by: Rob Bradford <[email protected]>
Copy link
Member

@sboeuf sboeuf left a comment

Choose a reason for hiding this comment

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

Great PR :)

device_cfg.id = Some(id.clone());
id
device_cfg.id = id.clone();
id.unwrap()
Copy link
Member

Choose a reason for hiding this comment

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

unwrap()?

Copy link
Member Author

Choose a reason for hiding this comment

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

@sboeuf Yes the previously the function returned a String which was then wrapped into a Some and saved with the plain String returned. Now it returns an Option<String> which is saved directly but the String needs to be returned so it needs to be unwrapped.

Copy link
Member Author

@rbradford rbradford Apr 16, 2020

Choose a reason for hiding this comment

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

We don't have to worry about None here as on the feature = "pci_support" case the function either errors or returns Some(..)

@sboeuf
Copy link
Member

sboeuf commented Apr 16, 2020

@sameo PTAL

@sameo sameo merged commit ea82632 into cloud-hypervisor:master Apr 16, 2020
@rbradford rbradford deleted the 2020-04-08-virtio-device-unplug branch April 17, 2020 10:10
likebreath added a commit to likebreath/cloud-hypervisor that referenced this pull request Jul 16, 2020
With recent changes (cloud-hypervisor#1030 cloud-hypervisor#1084), the '/vm.remove-device' API is no
longer restricted to remove VFIO PCI devices. It now supports (almost)
all hotpluggable devices, e.g. disk/net/pmem/fs/vsock.

Signed-off-by: Bo Chen <[email protected]>
sameo pushed a commit that referenced this pull request Jul 16, 2020
With recent changes (#1030 #1084), the '/vm.remove-device' API is no
longer restricted to remove VFIO PCI devices. It now supports (almost)
all hotpluggable devices, e.g. disk/net/pmem/fs/vsock.

Signed-off-by: Bo Chen <[email protected]>
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