Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
virtio-devices: balloon get pfn as u32
Browse files Browse the repository at this point in the history
pfn should be parsed as u32 instead of u64 in virtio-balloon.

Signed-off-by: Helin Guo <helinguo@linux.alibaba.com>
  • Loading branch information
HerlinCoder authored and studychao committed Feb 28, 2023
1 parent 46650c2 commit ca47164
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/dbs-virtio-devices/src/balloon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl<AS: DbsGuestAddressSpace, Q: QueueT + Send, R: GuestMemoryRegion>
let mut offset = 0u64;
while offset < avail_desc_len as u64 {
// Get pfn
let pfn: u64 = match mem.read_obj(GuestAddress(avail_desc.addr().0 + offset)) {
let pfn: u32 = match mem.read_obj(GuestAddress(avail_desc.addr().0 + offset)) {
Ok(ret) => ret,
Err(e) => {
error!(
Expand Down Expand Up @@ -345,8 +345,10 @@ impl<AS: DbsGuestAddressSpace, Q: QueueT + Send, R: GuestMemoryRegion>

let guest_addr = pfn << VIRTIO_BALLOON_PFN_SHIFT;

if let Some(region) = mem.find_region(GuestAddress(guest_addr)) {
let host_addr = mem.get_host_address(GuestAddress(guest_addr)).unwrap();
if let Some(region) = mem.find_region(GuestAddress(guest_addr.into())) {
let host_addr = mem
.get_host_address(GuestAddress(guest_addr.into()))
.unwrap();
if advice == libc::MADV_DONTNEED && region.file_offset().is_some() {
advice = libc::MADV_REMOVE;
}
Expand Down

0 comments on commit ca47164

Please sign in to comment.