Re: [PATCH 5/6] device assignment: support for assigning PCI devices to guests

Muli Ben-Yehuda
2008-10-28T15:36:19Z

On Tue, Oct 28, 2008 at 10:10:07PM +0800, Han, Weidong wrote:

> > + DEBUG("r_pio=%08x e_physbase=%08x r_virtbase=%08lx value=%08x\n",
> > + r_pio, (int)r_access->e_physbase,
> > + (unsigned long)r_access->r_virtbase, value);
>
> should be (unsigned long)r_access->u.r_virtbase

Thanks, actually it should be u.r_baseport for IO ports and there were
a number of other bogosities there too. Here's a quick incremental
patch compiled with DEBUG() enabled.

>From 9b917528647b55a1046a5a19d9e2427bb2d86db7 Mon Sep 17 00:00:00 2001
From: Muli Ben-Yehuda <muli@il.ibm.com>
Date: Tue, 28 Oct 2008 17:30:30 +0200
Subject: [PATCH 1/1] fix DEBUG statements

(thanks to Weidong Han for spotting)

Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
---
qemu/hw/device-assignment.c | 32 ++++++++++++++++----------------
1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c
index 89b05f9..8b56599 100644
--- a/qemu/hw/device-assignment.c
+++ b/qemu/hw/device-assignment.c
@@ -63,9 +63,9 @@ static void assigned_dev_ioport_writeb(void *opaque, uint32_t addr,
AssignedDevRegion *r_access = opaque;
uint32_t r_pio = guest_to_host_ioport(r_access, addr);

- DEBUG("r_pio=%08x e_physbase=%08x r_virtbase=%08lx value=%08x\n",
+ DEBUG("r_pio=%08x e_physbase=%08x r_baseport=%08lx value=%08x\n",
r_pio, (int)r_access->e_physbase,
- (unsigned long)r_access->r_virtbase, value);
+ (unsigned long)r_access->u.r_baseport, value);

outb(value, r_pio);
}
@@ -76,9 +76,9 @@ static void assigned_dev_ioport_writew(void *opaque, uint32_t addr,
AssignedDevRegion *r_access = opaque;
uint32_t r_pio = guest_to_host_ioport(r_access, addr);

- DEBUG("r_pio=%08x e_physbase=%08x r_virtbase=%08lx value=%08x\n",
- __func__, r_pio, (int)r_access->e_physbase,
- (unsigned long)r_access->r_virtbase, value);
+ DEBUG("r_pio=%08x e_physbase=%08x r_baseport=%08lx value=%08x\n",
+ r_pio, (int)r_access->e_physbase,
+ (unsigned long)r_access->u.r_baseport, value);

outw(value, r_pio);
}
@@ -89,9 +89,9 @@ static void assigned_dev_ioport_writel(void *opaque, uint32_t addr,
AssignedDevRegion *r_access = opaque;
uint32_t r_pio = guest_to_host_ioport(r_access, addr);

- DEBUG("%s: r_pio=%08x e_physbase=%08x r_virtbase=%08lx value=%08x\n",
+ DEBUG("r_pio=%08x e_physbase=%08x r_baseport=%08lx value=%08x\n",
r_pio, (int)r_access->e_physbase,
- (unsigned long)r_access->r_virtbase, value);
+ (unsigned long)r_access->u.r_baseport, value);

outl(value, r_pio);
}
@@ -104,9 +104,9 @@ static uint32_t assigned_dev_ioport_readb(void *opaque, uint32_t addr)

value = inb(r_pio);

- DEBUG("r_pio=%08x e_physbase=%08x r_virtbase=%08lx value=%08x\n",
+ DEBUG("r_pio=%08x e_physbase=%08x r_=%08lx value=%08x\n",
r_pio, (int)r_access->e_physbase,
- (unsigned long)r_access->r_virtbase, value);
+ (unsigned long)r_access->u.r_baseport, value);

return value;
}
@@ -119,9 +119,9 @@ static uint32_t assigned_dev_ioport_readw(void *opaque, uint32_t addr)

value = inw(r_pio);

- DEBUG("r_pio=%08x e_physbase=%08x r_virtbase=%08lx value=%08x\n",
+ DEBUG("r_pio=%08x e_physbase=%08x r_baseport=%08lx value=%08x\n",
r_pio, (int)r_access->e_physbase,
- (unsigned long)r_access->r_virtbase, value);
+ (unsigned long)r_access->u.r_baseport, value);

return value;
}
@@ -134,9 +134,9 @@ static uint32_t assigned_dev_ioport_readl(void *opaque, uint32_t addr)

value = inl(r_pio);

- DEBUG("r_pio=%08x e_physbase=%08x r_virtbase=%08lx value=%08x\n",
+ DEBUG("r_pio=%08x e_physbase=%08x r_baseport=%08lx value=%08x\n",
r_pio, (int)r_access->e_physbase,
- (unsigned long)r_access->r_virtbase, value);
+ (unsigned long)r_access->u.r_baseport, value);

return value;
}
@@ -151,8 +151,8 @@ static void assigned_dev_iomem_map(PCIDevice *pci_dev, int region_num,
int first_map = (region->e_size == 0);
int ret = 0;

- DEBUG("e_phys=%08x r_virt=%x type=%d len=%08x region_num=%d \n",
- e_phys, (uint32_t)region->r_virtbase, type, e_size, region_num);
+ DEBUG("e_phys=%08x r_virt=%p type=%d len=%08x region_num=%d \n",
+ e_phys, region->u.r_virtbase, type, e_size, region_num);

region->e_physbase = e_phys;
region->e_size = e_size;
@@ -425,7 +425,7 @@ again:
rp->valid = 1;
rp->base_addr = start;
rp->size = size;
- DEBUG("region %d size %d start 0x%x type %d resource_fd %d\n",
+ DEBUG("region %d size %d start 0x%llx type %d resource_fd %d\n",
r, rp->size, start, rp->type, rp->resource_fd);
}
fclose(f);
--
1.5.6.5