From c2f6dfce882323686d33604077746790de2f1be9 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Thu, 9 Jan 2020 14:50:15 +0100 Subject: [PATCH] vm-virtio: Fix VirtioDeviceType traits The From and Display traits were not handling some of the enum definitions. We no longer have a default case for Display so any future misses will fail at build time. Signed-off-by: Samuel Ortiz --- vm-virtio/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vm-virtio/src/lib.rs b/vm-virtio/src/lib.rs index d4bbc2552..ceed3ccdb 100755 --- a/vm-virtio/src/lib.rs +++ b/vm-virtio/src/lib.rs @@ -85,6 +85,7 @@ impl From for VirtioDeviceType { match t { 1 => VirtioDeviceType::TYPE_NET, 2 => VirtioDeviceType::TYPE_BLOCK, + 3 => VirtioDeviceType::TYPE_CONSOLE, 4 => VirtioDeviceType::TYPE_RNG, 5 => VirtioDeviceType::TYPE_BALLOON, 9 => VirtioDeviceType::TYPE_9P, @@ -107,14 +108,17 @@ impl fmt::Display for VirtioDeviceType { let output = match *self { VirtioDeviceType::TYPE_NET => "net", VirtioDeviceType::TYPE_BLOCK => "block", + VirtioDeviceType::TYPE_CONSOLE => "console", VirtioDeviceType::TYPE_RNG => "rng", VirtioDeviceType::TYPE_BALLOON => "balloon", VirtioDeviceType::TYPE_GPU => "gpu", VirtioDeviceType::TYPE_9P => "9p", + VirtioDeviceType::TYPE_INPUT => "input", VirtioDeviceType::TYPE_VSOCK => "vsock", + VirtioDeviceType::TYPE_IOMMU => "iommu", VirtioDeviceType::TYPE_FS => "fs", VirtioDeviceType::TYPE_PMEM => "pmem", - _ => return Err(std::fmt::Error), + VirtioDeviceType::TYPE_UNKNOWN => "UNKNOWN", }; write!(f, "{}", output) }