qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v7 17/21] multi-process: Retrieve PCI info from remote proces


From: Stefan Hajnoczi
Subject: Re: [PATCH v7 17/21] multi-process: Retrieve PCI info from remote process
Date: Thu, 2 Jul 2020 13:59:28 +0100

On Sat, Jun 27, 2020 at 10:09:39AM -0700, elena.ufimtseva@oracle.com wrote:
> @@ -267,3 +275,84 @@ const MemoryRegionOps proxy_mr_ops = {
>          .max_access_size = 1,
>      },
>  };
> +
> +static void probe_pci_info(PCIDevice *dev)
> +{
> +    PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
> +    DeviceClass *dc = DEVICE_CLASS(pc);
> +    PCIProxyDev *pdev = PCI_PROXY_DEV(dev);
> +    MPQemuMsg msg = { 0 }, ret =  { 0 };
> +    uint32_t orig_val, new_val, class;
> +    uint8_t type;
> +    int i, size;
> +    char *name;
> +    Error *local_err = NULL;
> +
> +    msg.bytestream = 0;
> +    msg.size = 0;
> +    msg.cmd = GET_PCI_INFO;
> +
> +    ret.data1.u64  = mpqemu_msg_send_reply_co(&msg, pdev->dev, &local_err);
> +    if (local_err) {
> +        error_report("Error while sending GET_PCI_INFO message");
> +    }
> +
> +    pc->vendor_id = ret.data1.ret_pci_info.vendor_id;
> +    pc->device_id = ret.data1.ret_pci_info.device_id;
> +    pc->class_id = ret.data1.ret_pci_info.class_id;
> +    pc->subsystem_id = ret.data1.ret_pci_info.subsystem_id;

Why are the vendor/device/class/subsystem IDs read using a special
GET_PCI_INFO message when they are already accessible from the PCI
Configuration Space? All the other values are being read from the config
space so I wonder why a special message is needed.

> +
> +    config_op_send(pdev, PCI_CLASS_DEVICE, &class, 1, PCI_CONFIG_READ);
> +    switch (class) {
> +    case PCI_BASE_CLASS_BRIDGE:
> +        set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
> +        break;
> +    case PCI_BASE_CLASS_STORAGE:
> +        set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
> +        break;
> +    case PCI_BASE_CLASS_NETWORK:
> +        set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
> +        break;
> +    case PCI_BASE_CLASS_INPUT:
> +        set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
> +        break;
> +    case PCI_BASE_CLASS_DISPLAY:
> +        set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
> +        break;
> +    case PCI_BASE_CLASS_PROCESSOR:
> +        set_bit(DEVICE_CATEGORY_CPU, dc->categories);
> +        break;
> +    default:
> +        set_bit(DEVICE_CATEGORY_MISC, dc->categories);
> +        break;
> +    }
> +
> +    for (i = 0; i < 6; i++) {

s/6/G_N_ELEMENTS(pdev->region)/

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]