Skip to contentSkip to conversation

piix: use pci_config_set_prog_interface()

PATCH In review Sebastian Herbszt 2 participants 9 messages Dec 20, 2010 – Dec 29, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 piix: use pci_config_set_prog_interface()

Use pci_config_set_prog_interface().

hw/ide/piix.c +1 -1
index 1cad906..2772e08 100644
@@ -135,7 +135,7 @@ static int pci_piix_ide_initfn(PCIIDEState *d)
 {
     uint8_t *pci_conf = d->dev.config;
 
-    pci_conf[PCI_CLASS_PROG] = 0x80; // legacy ATA mode
+    pci_config_set_prog_interface(pci_conf, 0x80); // legacy ATA mode
     pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_IDE);
 
     qemu_register_reset(piix3_reset, d);
#1 lore raw
Quoted 3 lines · Sebastian Herbszt

Use pci_config_set_prog_interface().

Since I was asked explicitly - I don't have a problem with these changes: both class and prog interface. However, they aren't all that useful in themselves.

For class, what I would like to see is a system where the device class is put in the qdev info table, and where -device ?
(and hopefully the legacy -help, -nic etc as well) use this information. pci_config_set_prog_interface can then have an assert to verify that value.
Maybe we can even make e.g. -device nic work.

In a similar way, pci_config_set_prog_interface would really become useful if we put the handling for the legacy classes in a central place (e.g. pci_class.c)

Any chance of doing something like the above? I'd be happy to apply such patches.

Quoted 14 lines
hw/ide/piix.c +1 -1
index 1cad906..2772e08 100644
@@ -135,7 +135,7 @@ static int pci_piix_ide_initfn(PCIIDEState *d)
 {
     uint8_t *pci_conf = d->dev.config;
 
-    pci_conf[PCI_CLASS_PROG] = 0x80; // legacy ATA mode
+    pci_config_set_prog_interface(pci_conf, 0x80); // legacy ATA mode
     pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_IDE);
 
     qemu_register_reset(piix3_reset, d);
#2 lore raw
Quoted 9 lines · Michael S. Tsirkin
Quoted 3 lines · Sebastian Herbszt

Use pci_config_set_prog_interface().

Since I was asked explicitly - I don't have a problem with these changes: both class and prog interface. However, they aren't all that useful in themselves.

Quoted 5 lines

For class, what I would like to see is a system where the device class is put in the qdev info table, and where -device ?
(and hopefully the legacy -help, -nic etc as well) use this information.

I am not sure if you mean something like the patch below.

Quoted 8 lines

pci_config_set_prog_interface can then have an assert to verify that value.
Maybe we can even make e.g. -device nic work.

In a similar way, pci_config_set_prog_interface would really become useful if we put the handling for the legacy classes in a central place (e.g. pci_class.c)

Which are "legacy classes"?

Quoted 2 lines

Any chance of doing something like the above? I'd be happy to apply such patches.

Sebastian

hw/e1000.c +1 -1
index af101bd..88ace8f 100644
@@ -1117,7 +1117,6 @@ static int pci_e1000_init(PCIDevice *pci_dev)
    /* TODO: we have no capabilities, so why is this bit set? */
    pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_CAP_LIST);
    pci_conf[PCI_REVISION_ID] = 0x03;
-    pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
    /* TODO: RST# value should be 0, PCI spec 6.2.4 */
    pci_conf[PCI_CACHE_LINE_SIZE] = 0x10;
 
@@ -1169,6 +1168,7 @@ static PCIDeviceInfo e1000_info = {
    .init       = pci_e1000_init,
    .exit       = pci_e1000_uninit,
    .romfile    = "pxe-e1000.bin",
+    .class      = PCI_CLASS_NETWORK_ETHERNET,
    .qdev.props = (Property[]) {
        DEFINE_NIC_PROPERTIES(E1000State, conf),
        DEFINE_PROP_END_OF_LIST(),
hw/pci.c +5 -0
index ef00d20..de0038c 100644
@@ -1620,6 +1620,11 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
                                     info->is_bridge);
    if (pci_dev == NULL)
        return -1;
+
+    if (info->class) {
+        pci_config_set_class(pci_dev->config, info->class);
+    }
+
    rc = info->init(pci_dev);
    if (rc != 0) {
        do_pci_unregister_device(pci_dev);
hw/pci.h +3 -0
index 17744dc..29b9280 100644
@@ -436,6 +436,9 @@ typedef struct {
 
    /* rom bar */
    const char *romfile;
+
+    /* class */
+    uint16_t class;

} PCIDeviceInfo;

void pci_qdev_register(PCIDeviceInfo *info);

#3 lore raw
Quoted 10 lines · Sebastian Herbszt
Quoted 9 lines · Michael S. Tsirkin
Quoted 3 lines · Sebastian Herbszt

Use pci_config_set_prog_interface().

Since I was asked explicitly - I don't have a problem with these changes: both class and prog interface. However, they aren't all that useful in themselves.

Quoted 7 lines
Quoted 5 lines

For class, what I would like to see is a system where the device class is put in the qdev info table, and where -device ?
(and hopefully the legacy -help, -nic etc as well) use this information.

I am not sure if you mean something like the patch below.

Not exactly

- I'd like to keep the pci_config_set_class in the devices, just make it do an assert.
- Nics already have DEFINE_NIC_PROPERTIES - can this be used somehow? Same for other devices ...
- This is still just moving bits around.
The main point would be to report device type in -device ? and friends.

Quoted 10 lines
Quoted 8 lines

pci_config_set_prog_interface can then have an assert to verify that value.
Maybe we can even make e.g. -device nic work.

In a similar way, pci_config_set_prog_interface would really become useful if we put the handling for the legacy classes in a central place (e.g. pci_class.c)

Which are "legacy classes"?

Some class/programming interface combinations let devices claim IO addresses not requested using a BAR. This is currently hard-coded in each such device.

Quoted 55 lines
Quoted 2 lines

Any chance of doing something like the above? I'd be happy to apply such patches.

Sebastian

hw/e1000.c +1 -1
index af101bd..88ace8f 100644
@@ -1117,7 +1117,6 @@ static int pci_e1000_init(PCIDevice *pci_dev)
    /* TODO: we have no capabilities, so why is this bit set? */
    pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_CAP_LIST);
    pci_conf[PCI_REVISION_ID] = 0x03;
-    pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
    /* TODO: RST# value should be 0, PCI spec 6.2.4 */
    pci_conf[PCI_CACHE_LINE_SIZE] = 0x10;
 
@@ -1169,6 +1168,7 @@ static PCIDeviceInfo e1000_info = {
    .init       = pci_e1000_init,
    .exit       = pci_e1000_uninit,
    .romfile    = "pxe-e1000.bin",
+    .class      = PCI_CLASS_NETWORK_ETHERNET,
    .qdev.props = (Property[]) {
        DEFINE_NIC_PROPERTIES(E1000State, conf),
        DEFINE_PROP_END_OF_LIST(),
hw/pci.c +5 -0
index ef00d20..de0038c 100644
@@ -1620,6 +1620,11 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
                                     info->is_bridge);
    if (pci_dev == NULL)
        return -1;
+
+    if (info->class) {
+        pci_config_set_class(pci_dev->config, info->class);
+    }
+
    rc = info->init(pci_dev);
    if (rc != 0) {
        do_pci_unregister_device(pci_dev);
hw/pci.h +3 -0
index 17744dc..29b9280 100644
@@ -436,6 +436,9 @@ typedef struct {
 
    /* rom bar */
    const char *romfile;
+
+    /* class */
+    uint16_t class;
 } PCIDeviceInfo;
 
 void pci_qdev_register(PCIDeviceInfo *info);
#4 lore raw
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Sebastian Herbszt
Quoted 14 lines · Michael S. Tsirkin
Quoted 3 lines · Sebastian Herbszt

Use pci_config_set_prog_interface().

Since I was asked explicitly - I don't have a problem with these changes: both class and prog interface. However, they aren't all that useful in themselves.

For class, what I would like to see is a system where the device class is put in the qdev info table, and where -device ?
(and hopefully the legacy -help, -nic etc as well) use this information.

Quoted 6 lines
Quoted 1 line

I am not sure if you mean something like the patch below.

Not exactly

- I'd like to keep the pci_config_set_class in the devices, just make it do an assert.

Assert on which condition?

Quoted 2 lines

- Nics already have DEFINE_NIC_PROPERTIES - can this be used somehow? Same for other devices ...

We got DEFINE_NIC_PROPERTIES and DEFINE_BLOCK_PROPERTIES. Something like DEFINE_PCI_PROPERTIES could be introduced, but i am not sure which device properties it should hold (vendor_id, device_id, class, etc?). Those will then be user-modifiable with e.g. -device e1000,pci_class=1234.

Sebastian

hw/e1000.c +1 -0
index af101bd..e302703 100644
@@ -1171,6 +1171,7 @@ static PCIDeviceInfo e1000_info = {
    .romfile    = "pxe-e1000.bin",
    .qdev.props = (Property[]) {
        DEFINE_NIC_PROPERTIES(E1000State, conf),
+        DEFINE_PROP_UINT16("pci_class", E1000State, dev.class, PCI_CLASS_NETWORK_ETHERNET),
        DEFINE_PROP_END_OF_LIST(),
    }

};

hw/pci.c +3 -0
index ef00d20..06bbf04 100644
@@ -1620,6 +1620,9 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
                                     info->is_bridge);
    if (pci_dev == NULL)
        return -1;
+
+    pci_config_set_class(pci_dev->config, pci_dev->class);
+
    rc = info->init(pci_dev);
    if (rc != 0) {
        do_pci_unregister_device(pci_dev);
hw/pci.h +3 -0
index 17744dc..5dc9053 100644
@@ -189,6 +189,9 @@ struct PCIDevice {
    char *romfile;
    ram_addr_t rom_offset;
    uint32_t rom_bar;
+
+    /* class */
+    uint16_t class;

};

PCIDevice *pci_register_device(PCIBus *bus, const char *name,

#5 lore raw
Quoted 18 lines · Sebastian Herbszt
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Sebastian Herbszt
Quoted 14 lines · Michael S. Tsirkin
Quoted 3 lines · Sebastian Herbszt

Use pci_config_set_prog_interface().

Since I was asked explicitly - I don't have a problem with these changes: both class and prog interface. However, they aren't all that useful in themselves.

For class, what I would like to see is a system where the device class is put in the qdev info table, and where -device ?
(and hopefully the legacy -help, -nic etc as well) use this information.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I am not sure if you mean something like the patch below.

Not exactly

- I'd like to keep the pci_config_set_class in the devices, just make it do an assert.

Assert on which condition?

That PCI class matches device type defined in qdev. This will serve to verify that all devices are converted properly.

Quoted 5 lines
Quoted 2 lines

- Nics already have DEFINE_NIC_PROPERTIES - can this be used somehow? Same for other devices ...

We got DEFINE_NIC_PROPERTIES and DEFINE_BLOCK_PROPERTIES. Something like DEFINE_PCI_PROPERTIES could be introduced, but i am not sure

This shouldn't have to do anything with PCI. We should define the device type as NIC, PCI class can be derived from that.

Quoted 4 lines

which device properties it should hold (vendor_id, device_id, class, etc?). Those will then be user-modifiable with e.g. -device e1000,pci_class=1234.

Sebastian

Why is this helpful?
- tweaking class will just break guests
- binary representation is unfriendly, let's not require users to read pci spec just to run qemu.

I can imagine some useful features implemented by sticking the type in qdev:
- -device ? would sort devices by type and print the type,
- something like this for qtree etc
- -help would get all e.g. nic models from qdev,
- allow easy to remember aliases with per-type scope (e.g. -device virtio,type=nic to be equivalent to -device virtio-net-pci)
- filter (for device ?, qtree etc) system devices that user has no business tweaking (could be type=system or something like that)

Quoted 31 lines
hw/e1000.c +1 -0
index af101bd..e302703 100644
@@ -1171,6 +1171,7 @@ static PCIDeviceInfo e1000_info = {
    .romfile    = "pxe-e1000.bin",
    .qdev.props = (Property[]) {
        DEFINE_NIC_PROPERTIES(E1000State, conf),
+        DEFINE_PROP_UINT16("pci_class", E1000State, dev.class, PCI_CLASS_NETWORK_ETHERNET),
        DEFINE_PROP_END_OF_LIST(),
    }
 };
hw/pci.c +3 -0
index ef00d20..06bbf04 100644
@@ -1620,6 +1620,9 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
                                     info->is_bridge);
    if (pci_dev == NULL)
        return -1;
+
+    pci_config_set_class(pci_dev->config, pci_dev->class);
+
    rc = info->init(pci_dev);
    if (rc != 0) {
        do_pci_unregister_device(pci_dev);
hw/pci.h +0 -0
index 17744dc..5dc9053 100644

hw/pci.h struct PCIDevice { · line 193

Quoted 5 lines
hw/pci.h +2 -0
@@ -189,6 +189,9 @@ struct PCIDevice {
    char *romfile;
    ram_addr_t rom_offset;
    uint32_t rom_bar;
+
+    /* class */

Please don't copy code into comments verbatim.

hw/pci.h struct PCIDevice { · line 194

Quoted 1 line
hw/pci.h +1 -0
+    uint16_t class;

Ugh. We have class in config already.

Quoted 4 lines
hw/pci.h +0 -0
 };
 
 PCIDevice *pci_register_device(PCIBus *bus, const char *name,
#6 lore raw
Quoted 34 lines · Michael S. Tsirkin
Quoted 18 lines · Sebastian Herbszt
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Sebastian Herbszt
Quoted 14 lines · Michael S. Tsirkin
Quoted 3 lines · Sebastian Herbszt

Use pci_config_set_prog_interface().

Since I was asked explicitly - I don't have a problem with these changes: both class and prog interface. However, they aren't all that useful in themselves.

For class, what I would like to see is a system where the device class is put in the qdev info table, and where -device ?
(and hopefully the legacy -help, -nic etc as well) use this information.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I am not sure if you mean something like the patch below.

Not exactly

- I'd like to keep the pci_config_set_class in the devices, just make it do an assert.

Assert on which condition?

That PCI class matches device type defined in qdev. This will serve to verify that all devices are converted properly.

Quoted 3 lines
Quoted 2 lines

- Nics already have DEFINE_NIC_PROPERTIES - can this be used somehow? Same for other devices ...

Quoted 6 lines
Quoted 2 lines

We got DEFINE_NIC_PROPERTIES and DEFINE_BLOCK_PROPERTIES. Something like DEFINE_PCI_PROPERTIES could be introduced, but i am not sure

This shouldn't have to do anything with PCI. We should define the device type as NIC, PCI class can be derived from that.

So you want to introduce a device property like "device_type" and set it to "NIC" and then translate "NIC" to the correct PCI class code. Are you sure this is unambiguous? "NIC" could be ethernet or token ring. A generic name like "HBA" could translate to even more codes (scsi, ide, raid, sata, ...).

Quoted 9 lines
Quoted 4 lines

which device properties it should hold (vendor_id, device_id, class, etc?). Those will then be user-modifiable with e.g. -device e1000,pci_class=1234.

Sebastian

Why is this helpful?
- tweaking class will just break guests
- binary representation is unfriendly, let's not require users to read pci spec just to run qemu.

"pci_class" is optional. I just wanted to show that qdev device properties are user-modifiable and i didn't find a way to prevent this.

Quoted 6 lines

I can imagine some useful features implemented by sticking the type in qdev:
- -device ? would sort devices by type and print the type,
- something like this for qtree etc
- -help would get all e.g. nic models from qdev,
- allow easy to remember aliases with per-type scope (e.g. -device virtio,type=nic to be equivalent to -device virtio-net-pci)

Is this just a virtio problem?

Quoted 42 lines

- filter (for device ?, qtree etc) system devices that user has no business tweaking (could be type=system or something like that)

Quoted 31 lines
hw/e1000.c +1 -0
index af101bd..e302703 100644
@@ -1171,6 +1171,7 @@ static PCIDeviceInfo e1000_info = {
    .romfile    = "pxe-e1000.bin",
    .qdev.props = (Property[]) {
        DEFINE_NIC_PROPERTIES(E1000State, conf),
+        DEFINE_PROP_UINT16("pci_class", E1000State, dev.class, PCI_CLASS_NETWORK_ETHERNET),
        DEFINE_PROP_END_OF_LIST(),
    }
 };
hw/pci.c +3 -0
index ef00d20..06bbf04 100644
@@ -1620,6 +1620,9 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
                                     info->is_bridge);
    if (pci_dev == NULL)
        return -1;
+
+    pci_config_set_class(pci_dev->config, pci_dev->class);
+
    rc = info->init(pci_dev);
    if (rc != 0) {
        do_pci_unregister_device(pci_dev);
hw/pci.h +0 -0
index 17744dc..5dc9053 100644

hw/pci.h struct PCIDevice { · line 193

Quoted 5 lines
hw/pci.h +2 -0
@@ -189,6 +189,9 @@ struct PCIDevice {
    char *romfile;
    ram_addr_t rom_offset;
    uint32_t rom_bar;
+
+    /* class */

Please don't copy code into comments verbatim.

Quoted 3 lines

hw/pci.h struct PCIDevice { · line 194

Quoted 1 line
hw/pci.h +1 -0
+    uint16_t class;

Ugh. We have class in config already.

But i could not get qdev to use it.

Quoted 4 lines

hw/pci.h struct PCIDevice { · line 197

Quoted 4 lines
hw/pci.h +0 -0
 };
 
 PCIDevice *pci_register_device(PCIBus *bus, const char *name,

Sebastian

#7 lore raw
Quoted 38 lines · Sebastian Herbszt
Quoted 37 lines · Michael S. Tsirkin
Quoted 18 lines · Sebastian Herbszt
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Sebastian Herbszt
Quoted 14 lines · Michael S. Tsirkin
Quoted 3 lines · Sebastian Herbszt

Use pci_config_set_prog_interface().

Since I was asked explicitly - I don't have a problem with these changes: both class and prog interface. However, they aren't all that useful in themselves.

For class, what I would like to see is a system where the device class is put in the qdev info table, and where -device ?
(and hopefully the legacy -help, -nic etc as well) use this information.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I am not sure if you mean something like the patch below.

Not exactly

- I'd like to keep the pci_config_set_class in the devices, just make it do an assert.

Assert on which condition?

That PCI class matches device type defined in qdev. This will serve to verify that all devices are converted properly.

Quoted 5 lines
Quoted 2 lines

- Nics already have DEFINE_NIC_PROPERTIES - can this be used somehow? Same for other devices ...

We got DEFINE_NIC_PROPERTIES and DEFINE_BLOCK_PROPERTIES. Something like DEFINE_PCI_PROPERTIES could be introduced, but i am not sure

Quoted 6 lines
Quoted 3 lines

This shouldn't have to do anything with PCI. We should define the device type as NIC, PCI class can be derived from that.

So you want to introduce a device property like "device_type" and set it to "NIC" and then translate "NIC" to the correct PCI class code. Are you sure this is unambiguous?

It does not need to be, that's why I would like to keep the code in device init that sets the PCI class.
We would just check that it matches.

Quoted 2 lines

"NIC" could be ethernet or token ring. A generic name like "HBA" could translate to even more codes (scsi, ide, raid, sata, ...).

I don't insist on NIC. Maybe ethernet is a good thing. Maybe pci_class_descriptions is a good starting point.

Quoted 14 lines
Quoted 10 lines
Quoted 5 lines

which device properties it should hold (vendor_id, device_id, class, etc?). Those will then be user-modifiable with e.g. -device e1000,pci_class=1234.

Sebastian

Why is this helpful?
- tweaking class will just break guests
- binary representation is unfriendly, let's not require users to read pci spec just to run qemu.

"pci_class" is optional. I just wanted to show that qdev device properties are user-modifiable and i didn't find a way to prevent this.

Quoted 8 lines
Quoted 6 lines

I can imagine some useful features implemented by sticking the type in qdev:
- -device ? would sort devices by type and print the type,
- something like this for qtree etc
- -help would get all e.g. nic models from qdev,
- allow easy to remember aliases with per-type scope (e.g. -device virtio,type=nic to be equivalent to -device virtio-net-pci)

Is this just a virtio problem?

Not sure. I think usb has this, I think there are others.

Quoted 42 lines
Quoted 42 lines

- filter (for device ?, qtree etc) system devices that user has no business tweaking (could be type=system or something like that)

Quoted 31 lines
hw/e1000.c +1 -0
index af101bd..e302703 100644
@@ -1171,6 +1171,7 @@ static PCIDeviceInfo e1000_info = {
   .romfile    = "pxe-e1000.bin",
   .qdev.props = (Property[]) {
       DEFINE_NIC_PROPERTIES(E1000State, conf),
+        DEFINE_PROP_UINT16("pci_class", E1000State, dev.class, PCI_CLASS_NETWORK_ETHERNET),
       DEFINE_PROP_END_OF_LIST(),
   }
 };
hw/pci.c +3 -0
index ef00d20..06bbf04 100644
@@ -1620,6 +1620,9 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
                                    info->is_bridge);
   if (pci_dev == NULL)
       return -1;
+
+    pci_config_set_class(pci_dev->config, pci_dev->class);
+
   rc = info->init(pci_dev);
   if (rc != 0) {
       do_pci_unregister_device(pci_dev);
hw/pci.h +0 -0
index 17744dc..5dc9053 100644

hw/pci.h struct PCIDevice { · line 193

Quoted 5 lines
hw/pci.h +2 -0
@@ -189,6 +189,9 @@ struct PCIDevice {
   char *romfile;
   ram_addr_t rom_offset;
   uint32_t rom_bar;
+
+    /* class */

Please don't copy code into comments verbatim.

Quoted 5 lines
Quoted 3 lines

hw/pci.h struct PCIDevice { · line 194

Quoted 1 line
hw/pci.h +1 -0
+    uint16_t class;

Ugh. We have class in config already.

But i could not get qdev to use it.

That's a problem for qdev to solve :)

Quoted 6 lines
Quoted 4 lines

hw/pci.h struct PCIDevice { · line 197

Quoted 4 lines
hw/pci.h +0 -0
 };
 
 PCIDevice *pci_register_device(PCIBus *bus, const char *name,

Sebastian

#8 lore raw
In reply to Sebastian Herbszt
Quoted 52 lines · Sebastian Herbszt
Quoted 34 lines · Michael S. Tsirkin
Quoted 18 lines · Sebastian Herbszt
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Sebastian Herbszt
Quoted 14 lines · Michael S. Tsirkin
Quoted 3 lines · Sebastian Herbszt

Use pci_config_set_prog_interface().

Since I was asked explicitly - I don't have a problem with these changes: both class and prog interface. However, they aren't all that useful in themselves.

For class, what I would like to see is a system where the device class is put in the qdev info table, and where -device ?
(and hopefully the legacy -help, -nic etc as well) use this information.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I am not sure if you mean something like the patch below.

Not exactly

- I'd like to keep the pci_config_set_class in the devices, just make it do an assert.

Assert on which condition?

That PCI class matches device type defined in qdev. This will serve to verify that all devices are converted properly.

Quoted 3 lines
Quoted 2 lines

- Nics already have DEFINE_NIC_PROPERTIES - can this be used somehow? Same for other devices ...

Quoted 6 lines
Quoted 2 lines

We got DEFINE_NIC_PROPERTIES and DEFINE_BLOCK_PROPERTIES. Something like DEFINE_PCI_PROPERTIES could be introduced, but i am not sure

This shouldn't have to do anything with PCI. We should define the device type as NIC, PCI class can be derived from that.

So you want to introduce a device property like "device_type" and set it to "NIC" and then translate "NIC" to the correct PCI class code. Are you sure this is unambiguous? "NIC" could be ethernet or token ring. A generic name like "HBA" could translate to even more codes (scsi, ide, raid, sata, ...).

Quoted 5 lines
Quoted 4 lines

which device properties it should hold (vendor_id, device_id, class, etc?). Those will then be user-modifiable with e.g. -device e1000,pci_class=1234.

Sebastian

Quoted 8 lines
Quoted 4 lines

Why is this helpful?
- tweaking class will just break guests
- binary representation is unfriendly, let's not require users to read pci spec just to run qemu.

"pci_class" is optional.
I just wanted to show that qdev device properties are user-modifiable and i didn't find a way to prevent this.

Ah, ok.
I think properties starting with x- are internal.
It's a kind of undocumented thing.

Signature · 1 line
MST