From 60f55da93784b55cfb97c98725268e87665cc56e Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Wed, 24 Oct 2018 10:20:24 -0700 Subject: [PATCH] devices: balloon: define features as shift counts This matches the definitions from the virtio specification and makes balloon consistent with the other virtio devices in crosvm. BUG=None TEST=build_test.py Change-Id: I9dd6b6ec981944e28eaf6bc92332db5ec326433b Signed-off-by: Daniel Verkamp Reviewed-on: https://chromium-review.googlesource.com/1313011 Commit-Ready: ChromeOS CL Exonerator Bot Reviewed-by: Dylan Reid --- devices/src/virtio/balloon.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/devices/src/virtio/balloon.rs b/devices/src/virtio/balloon.rs index 2bd1ba3ca9..cc6a7e638c 100644 --- a/devices/src/virtio/balloon.rs +++ b/devices/src/virtio/balloon.rs @@ -37,8 +37,8 @@ const QUEUE_SIZES: &'static [u16] = &[QUEUE_SIZE, QUEUE_SIZE]; const VIRTIO_BALLOON_PFN_SHIFT: u32 = 12; // The feature bitmap for virtio balloon -const VIRTIO_BALLOON_F_MUST_TELL_HOST: u32 = 0x01; // Tell before reclaiming pages -const VIRTIO_BALLOON_F_DEFLATE_ON_OOM: u32 = 0x04; // Deflate balloon on OOM +const VIRTIO_BALLOON_F_MUST_TELL_HOST: u32 = 0; // Tell before reclaiming pages +const VIRTIO_BALLOON_F_DEFLATE_ON_OOM: u32 = 2; // Deflate balloon on OOM // BalloonConfig is modified by the worker and read from the device thread. #[derive(Default)] @@ -235,7 +235,7 @@ impl Balloon { }), kill_evt: None, // TODO(dgreid) - Add stats queue feature. - features: VIRTIO_BALLOON_F_MUST_TELL_HOST | VIRTIO_BALLOON_F_DEFLATE_ON_OOM, + features: 1 << VIRTIO_BALLOON_F_MUST_TELL_HOST | 1 << VIRTIO_BALLOON_F_DEFLATE_ON_OOM, }) } } @@ -297,7 +297,7 @@ impl VirtioDevice for Balloon { fn features(&self, page: u32) -> u32 { match page { - 0 => VIRTIO_BALLOON_F_MUST_TELL_HOST | VIRTIO_BALLOON_F_DEFLATE_ON_OOM, + 0 => 1 << VIRTIO_BALLOON_F_MUST_TELL_HOST | 1 << VIRTIO_BALLOON_F_DEFLATE_ON_OOM, _ => 0u32, } }