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

Han, Weidong
2008-10-29T08:23:09Z

Muli Ben-Yehuda wrote:
> On Tue, Oct 28, 2008 at 10:45:57AM -0500, Anthony Liguori wrote:
>
>>> +ifeq ($(USE_KVM), 1)
>>> +OBJS+= device-assignment.o
>>> +endif
>>
>> I don't think you want to build this on PPC so I think you need a
>> stronger check.
>
> Good point. How about checking TARGET_BASE_ARCH = i386?
>
>>> +static void assigned_dev_ioport_writel(void *opaque, uint32_t addr,
>>> + uint32_t value)
>>> +{
>>> + 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", + r_pio, (int)r_access->e_physbase,
>>> + (unsigned long)r_access->r_virtbase, value);
>>>
>>
>> The format doesn't match the parameter count.
>
> Yep, already fixed.
>
>>> +static void assigned_dev_ioport_map(PCIDevice *pci_dev, int
>>> region_num, + uint32_t addr,
>>> uint32_t size, int type) +{
>>> + AssignedDevice *r_dev = (AssignedDevice *) pci_dev;
>>> + AssignedDevRegion *region = &r_dev->v_addrs[region_num];
>>> + uint32_t old_port = region->u.r_baseport;
>>> + uint32_t old_num = region->e_size;
>>> + int first_map = (old_num == 0);
>>> + struct ioperm_data data;
>>> + int i;
>>> +
>>> + region->e_physbase = addr;
>>> + region->e_size = size;
>>> +
>>> + DEBUG("e_phys=0x%x r_baseport=%x type=0x%x len=%d
>>> region_num=%d \n", + addr, region->u.r_baseport, type,
>>> size, region_num); + + memset(&data, 0, sizeof(data));
>>> +
>>> + if (!first_map) {
>>> + data.start_port = old_port;
>>> + data.num = old_num; + data.turn_on = 0;
>>> +
>>> + for (i = 0; i < smp_cpus; ++i)
>>> + kvm_ioperm(qemu_kvm_cpu_env(i), &data);
>>>
>>
>> How does this interact with VCPU hot-plug?
>
> I have no idea. Weidong?

maybe we need to keep an assigned io port range list, when VCPU hot-plug in, do ioperm for those io ports on new VCPU. Has VCPU hot-plug been already supported?

Regards,
Weidong