All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Fishman <afishman@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Subject: [PATCH] virtio-pci: add a PCIe Device Serial Number (DSN)
Date: Wed,  2 Dec 2026 12:49:35 +0200	[thread overview]
Message-ID: <20261202104935.29518-1-afishman@redhat.com> (raw)

Add a 64-bit x-pcie-dsn property to the shared virtio-pci transport.
This lets a user supply a stable PCIe identity for endpoints such
as virtio-blk devices and virtio-scsi controllers.

When Windows processes the PCIe DSN capability, it can use the DSN
to construct a PnP instance ID that remains stable across PCI
topology changes.

Signed-off-by: Alex Fishman <afishman@redhat.com>
---
 hw/virtio/virtio-pci.c         | 7 +++++++
 include/hw/virtio/virtio-pci.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 9ff8b63..f2f6cb6 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -2306,6 +2306,12 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
             proxy->last_pcie_cap_offset += PCI_EXT_CAP_ATS_SIZEOF;
         }
 
+        if (proxy->dsn) {
+            pcie_dev_ser_num_init(pci_dev, proxy->last_pcie_cap_offset,
+                                  proxy->dsn);
+            proxy->last_pcie_cap_offset += PCI_EXT_CAP_DSN_SIZEOF;
+        }
+
         /* Set Function Level Reset capability bit */
         pcie_cap_flr_init(pci_dev);
     } else {
@@ -2415,6 +2421,7 @@ static const Property virtio_pci_properties[] = {
                     VIRTIO_PCI_FLAG_PM_NO_SOFT_RESET_BIT, false),
     DEFINE_PROP_BIT("aer", VirtIOPCIProxy, flags,
                     VIRTIO_PCI_FLAG_AER_BIT, false),
+    DEFINE_PROP_UINT64("x-pcie-dsn", VirtIOPCIProxy, dsn, 0),
 };
 
 static void virtio_pci_dc_realize(DeviceState *qdev, Error **errp)
diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h
index b2738ce..d4f3ba7 100644
--- a/include/hw/virtio/virtio-pci.h
+++ b/include/hw/virtio/virtio-pci.h
@@ -141,6 +141,7 @@ struct VirtIOPCIProxy {
     uint32_t nvectors;
     uint32_t dfselect;
     uint32_t gfselect;
+    uint64_t dsn;
     uint32_t guest_features[VIRTIO_FEATURES_NU32S];
     VirtIOPCIQueue vqs[VIRTIO_QUEUE_MAX];
 
-- 
2.54.0 (Apple Git-157)



             reply	other threads:[~2026-12-02 10:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 10:49 Alex Fishman [this message]
2026-12-02 12:26 ` [PATCH] virtio-pci: add a PCIe Device Serial Number (DSN) Michael S. Tsirkin
2026-12-02 12:29 ` Michael S. Tsirkin
2026-12-02 12:37 ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202104935.29518-1-afishman@redhat.com \
    --to=afishman@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.