Skip to contentSkip to conversation

virtio-pci: Add subsystem-vendor-id property

PATCH In review [email protected] 3 participants 7 messages Dec 13, 2017 – May 7, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-pci: Add subsystem-vendor-id property

From: Ben Warren <[email protected]>

Now that virtio-win guest drivers provided by non-Redhat vendors need to use a different Subsystem Vendor ID value, a way is needed to set this parameter on the host. This works with all of the PCI-based devices, such as NetKVM, viostor, vioscsi, vioserial and balloon.

---
 hw/virtio/virtio-pci.c | 5 +++++
 hw/virtio/virtio-pci.h | 1 +
 2 files changed, 6 insertions(+)
hw/virtio/virtio-pci.c +5 -0
index e92837c..b5c86e3 100644
@@ -1757,6 +1757,9 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
     if (proxy->disable_legacy == ON_OFF_AUTO_AUTO) {
         proxy->disable_legacy = pcie_port ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF;
     }
+    /* Set the PCI Subsystem Vendor ID */
+    k->parent_class.subsystem_vendor_id = proxy->subsystem_vendor_id;
+    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, proxy->subsystem_vendor_id);
 
     if (!virtio_pci_modern(proxy) && !virtio_pci_legacy(proxy)) {
         error_setg(errp, "device cannot work as neither modern nor legacy mode"
@@ -1876,6 +1879,8 @@ static Property virtio_pci_properties[] = {
                     VIRTIO_PCI_FLAG_INIT_LNKCTL_BIT, true),
     DEFINE_PROP_BIT("x-pcie-pm-init", VirtIOPCIProxy, flags,
                     VIRTIO_PCI_FLAG_INIT_PM_BIT, true),
+    DEFINE_PROP_UINT16("subsystem-vendor-id", VirtIOPCIProxy,
+                       subsystem_vendor_id, PCI_VENDOR_ID_REDHAT_QUMRANET),
     DEFINE_PROP_END_OF_LIST(),
 };
 
hw/virtio/virtio-pci.h +1 -0
index 12d3a90..8a897ea 100644
@@ -186,6 +186,7 @@ struct VirtIOPCIProxy {
     VirtIOIRQFD *vector_irqfd;
     int nvqs_with_notifiers;
     VirtioBusState bus;
+    uint16_t subsystem_vendor_id;
 };
 
 static inline bool virtio_pci_modern(VirtIOPCIProxy *proxy)
Signature · 1 line
2.7.4
#1 lore raw
Quoted 7 lines · Ben Warren via Qemu-devel

From: Ben Warren <[email protected]>

Now that virtio-win guest drivers provided by non-Redhat vendors need to use a different Subsystem Vendor ID value, a way is needed to set this parameter on the host. This works with all of the PCI-based devices, such as NetKVM, viostor, vioscsi, vioserial and balloon.

Quoted 5 lines
---
 hw/virtio/virtio-pci.c | 5 +++++
 hw/virtio/virtio-pci.h | 1 +
 2 files changed, 6 insertions(+)

Is it possible to put this property in hw/pci/pci.c:pci_props[] so that users can override the Subsystem Vendor ID for any PCI adapter, not just virtio-pci?

#2 lore raw
Quoted 14 lines · Stefan Hajnoczi
Quoted 7 lines · Ben Warren via Qemu-devel

From: Ben Warren <[email protected]>

Now that virtio-win guest drivers provided by non-Redhat vendors need to use a different Subsystem Vendor ID value, a way is needed to set this parameter on the host. This works with all of the PCI-based devices, such as NetKVM, viostor, vioscsi, vioserial and balloon.

Quoted 5 lines
---
 hw/virtio/virtio-pci.c | 5 +++++
 hw/virtio/virtio-pci.h | 1 +
 2 files changed, 6 insertions(+)
Quoted 3 lines

Is it possible to put this property in hw/pci/pci.c:pci_props[] so that users can override the Subsystem Vendor ID for any PCI adapter, not just virtio-pci?

The difficulty is that some devices override the ID you would set, and there's no way for management to find out.
So I think virtio is preferable for now.

#3 lore raw

Hi Michael,

It looks like this was never applied. Can it be, please?

Quoted 17 lines · Michael S. Tsirkin
Quoted 1 line · Stefan Hajnoczi

On Wed, Dec 13, 2017 at 12:26:44AM -0800, Ben Warren via Qemu-devel

Quoted 3 lines · wrote:
Quoted 3 lines

From: Ben Warren <[email protected]>

Now that virtio-win guest drivers provided by non-Redhat vendors need

to

Quoted 10 lines
Quoted 9 lines

use a different Subsystem Vendor ID value, a way is needed to set this parameter on the host. This works with all of the PCI-based devices, such as NetKVM, viostor, vioscsi, vioserial and balloon.

---
 hw/virtio/virtio-pci.c | 5 +++++
 hw/virtio/virtio-pci.h | 1 +
 2 files changed, 6 insertions(+)
Quoted 8 lines
Quoted 3 lines

Is it possible to put this property in hw/pci/pci.c:pci_props[] so that users can override the Subsystem Vendor ID for any PCI adapter, not just virtio-pci?

The difficulty is that some devices override the ID you would set, and there's no way for management to find out.
So I think virtio is preferable for now.

thanks,
Ben

#4 lore raw
In reply to [email protected]
Quoted 8 lines · On Wed, Dec 13, 2017 at 12:26:44AM -0800, [email protected] wrote:

From: Ben Warren <[email protected]>

Now that virtio-win guest drivers provided by non-Redhat vendors need to use a different Subsystem Vendor ID value, a way is needed to set this parameter on the host. This works with all of the PCI-based devices, such as NetKVM, viostor, vioscsi, vioserial and balloon.

I applied a related patch by Ladi, pls take a look.

Quoted 42 lines
---
 hw/virtio/virtio-pci.c | 5 +++++
 hw/virtio/virtio-pci.h | 1 +
 2 files changed, 6 insertions(+)
hw/virtio/virtio-pci.c +5 -0
index e92837c..b5c86e3 100644
@@ -1757,6 +1757,9 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
     if (proxy->disable_legacy == ON_OFF_AUTO_AUTO) {
         proxy->disable_legacy = pcie_port ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF;
     }
+    /* Set the PCI Subsystem Vendor ID */
+    k->parent_class.subsystem_vendor_id = proxy->subsystem_vendor_id;
+    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, proxy->subsystem_vendor_id);
 
     if (!virtio_pci_modern(proxy) && !virtio_pci_legacy(proxy)) {
         error_setg(errp, "device cannot work as neither modern nor legacy mode"
@@ -1876,6 +1879,8 @@ static Property virtio_pci_properties[] = {
                     VIRTIO_PCI_FLAG_INIT_LNKCTL_BIT, true),
     DEFINE_PROP_BIT("x-pcie-pm-init", VirtIOPCIProxy, flags,
                     VIRTIO_PCI_FLAG_INIT_PM_BIT, true),
+    DEFINE_PROP_UINT16("subsystem-vendor-id", VirtIOPCIProxy,
+                       subsystem_vendor_id, PCI_VENDOR_ID_REDHAT_QUMRANET),
     DEFINE_PROP_END_OF_LIST(),
 };
 
hw/virtio/virtio-pci.h +1 -0
index 12d3a90..8a897ea 100644
@@ -186,6 +186,7 @@ struct VirtIOPCIProxy {
     VirtIOIRQFD *vector_irqfd;
     int nvqs_with_notifiers;
     VirtioBusState bus;
+    uint16_t subsystem_vendor_id;
 };
 
 static inline bool virtio_pci_modern(VirtIOPCIProxy *proxy)
Signature · 1 line
2.7.4
author
#5 lore raw

Hi Michael,

Quoted 5 lines · Michael S. Tsirkin
Quoted 2 lines · On Wed, Dec 13, 2017 at 12:26:44AM -0800, [email protected] wrote:

From: Ben Warren <[email protected]>

Quoted 9 lines
Quoted 6 lines

Now that virtio-win guest drivers provided by non-Redhat vendors need to use a different Subsystem Vendor ID value, a way is needed to set this parameter on the host. This works with all of the PCI-based devices, such as NetKVM, viostor, vioscsi, vioserial and balloon.

I applied a related patch by Ladi, pls take a look.

If you’re talking about the one titled "virtio-pci: Don't force Subsystem Vendor ID = Vendor ID”, then this is complementary. If it’s another one, I must have missed it. The patch I’m aware of doesn’t provide any way of setting the subsystem vendor ID, which is needed.

BTW - would you prefer this to be contained to virtio-pci, or all of PCI, as another reviewer suggested. Either is easy.

Quoted 42 lines
Quoted 42 lines

---
hw/virtio/virtio-pci.c | 5 +++++
hw/virtio/virtio-pci.h | 1 +

2 files changed, 6 insertions(+)
hw/virtio/virtio-pci.c +5 -0
index e92837c..b5c86e3 100644
@@ -1757,6 +1757,9 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
    if (proxy->disable_legacy == ON_OFF_AUTO_AUTO) {
        proxy->disable_legacy = pcie_port ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF;
    }
+    /* Set the PCI Subsystem Vendor ID */
+    k->parent_class.subsystem_vendor_id = proxy->subsystem_vendor_id;
+    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, proxy->subsystem_vendor_id);
 
    if (!virtio_pci_modern(proxy) && !virtio_pci_legacy(proxy)) {
        error_setg(errp, "device cannot work as neither modern nor legacy mode"
@@ -1876,6 +1879,8 @@ static Property virtio_pci_properties[] = {
                    VIRTIO_PCI_FLAG_INIT_LNKCTL_BIT, true),
    DEFINE_PROP_BIT("x-pcie-pm-init", VirtIOPCIProxy, flags,
                    VIRTIO_PCI_FLAG_INIT_PM_BIT, true),
+    DEFINE_PROP_UINT16("subsystem-vendor-id", VirtIOPCIProxy,
+                       subsystem_vendor_id, PCI_VENDOR_ID_REDHAT_QUMRANET),
    DEFINE_PROP_END_OF_LIST(),
 };
 
hw/virtio/virtio-pci.h +1 -0
index 12d3a90..8a897ea 100644
@@ -186,6 +186,7 @@ struct VirtIOPCIProxy {
    VirtIOIRQFD *vector_irqfd;
    int nvqs_with_notifiers;
    VirtioBusState bus;
+    uint16_t subsystem_vendor_id;
 };
 
 static inline bool virtio_pci_modern(VirtIOPCIProxy *proxy)
Signature · 1 line
2.7.4
#6 lore raw
Quoted 12 lines · Ben Warren

Hi Michael,

Quoted 10 lines · Michael S. Tsirkin
Quoted 7 lines · On Wed, Dec 13, 2017 at 12:26:44AM -0800, [email protected] wrote:

From: Ben Warren <[email protected]>

Now that virtio-win guest drivers provided by non-Redhat vendors need to use a different Subsystem Vendor ID value, a way is needed to set this parameter on the host. This works with all of the PCI-based devices, such as NetKVM, viostor, vioscsi, vioserial and balloon.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I applied a related patch by Ladi, pls take a look.

If you’re talking about the one titled "virtio-pci: Don't force Subsystem Vendor ID = Vendor ID”, then this is complementary. If it’s another one, I must have missed it. The patch I’m aware of doesn’t provide any way of setting the subsystem vendor ID, which is needed.

BTW - would you prefer this to be contained to virtio-pci, or all of PCI, as another reviewer suggested. Either is easy.

Let me respond to that one.

Quoted 43 lines
Quoted 42 lines
Quoted 42 lines

---
hw/virtio/virtio-pci.c | 5 +++++
hw/virtio/virtio-pci.h | 1 +

2 files changed, 6 insertions(+)
hw/virtio/virtio-pci.c +5 -0
index e92837c..b5c86e3 100644
@@ -1757,6 +1757,9 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
    if (proxy->disable_legacy == ON_OFF_AUTO_AUTO) {
        proxy->disable_legacy = pcie_port ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF;
    }
+    /* Set the PCI Subsystem Vendor ID */
+    k->parent_class.subsystem_vendor_id = proxy->subsystem_vendor_id;
+    pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, proxy->subsystem_vendor_id);
 
    if (!virtio_pci_modern(proxy) && !virtio_pci_legacy(proxy)) {
        error_setg(errp, "device cannot work as neither modern nor legacy mode"
@@ -1876,6 +1879,8 @@ static Property virtio_pci_properties[] = {
                    VIRTIO_PCI_FLAG_INIT_LNKCTL_BIT, true),
    DEFINE_PROP_BIT("x-pcie-pm-init", VirtIOPCIProxy, flags,
                    VIRTIO_PCI_FLAG_INIT_PM_BIT, true),
+    DEFINE_PROP_UINT16("subsystem-vendor-id", VirtIOPCIProxy,
+                       subsystem_vendor_id, PCI_VENDOR_ID_REDHAT_QUMRANET),
    DEFINE_PROP_END_OF_LIST(),
 };
 
hw/virtio/virtio-pci.h +1 -0
index 12d3a90..8a897ea 100644
@@ -186,6 +186,7 @@ struct VirtIOPCIProxy {
    VirtIOIRQFD *vector_irqfd;
    int nvqs_with_notifiers;
    VirtioBusState bus;
+    uint16_t subsystem_vendor_id;
 };
 
 static inline bool virtio_pci_modern(VirtIOPCIProxy *proxy)
Signature · 1 line
2.7.4