diff --git a/hw/pci/ahci.c b/hw/pci/ahci.c index bc92efd5d..0fa942274 100644 --- a/hw/pci/ahci.c +++ b/hw/pci/ahci.c @@ -2312,10 +2312,11 @@ pci_ahci_read(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx, static int pci_ahci_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts, int atapi) { - char bident[sizeof("XX:XX:XX")]; + char bident[16]; struct blockif_ctxt *bctxt; struct pci_ahci_vdev *ahci_dev; - int ret, slots, p; + int ret, slots; + uint8_t p; MD5_CTX mdctx; u_char digest[16]; char *next, *next2; @@ -2365,7 +2366,7 @@ pci_ahci_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts, int atapi) * Attempt to open the backing image. Use the PCI slot/func * and the port number for the identifier string. */ - snprintf(bident, sizeof(bident), "%d:%d:%d", dev->slot, + snprintf(bident, sizeof(bident), "%02x:%02x:%02x", dev->slot, dev->func, p); bctxt = blockif_open(opts, bident); if (bctxt == NULL) { diff --git a/hw/pci/virtio/virtio_block.c b/hw/pci/virtio/virtio_block.c index e4a3dd78b..810967fd0 100644 --- a/hw/pci/virtio/virtio_block.c +++ b/hw/pci/virtio/virtio_block.c @@ -285,7 +285,7 @@ virtio_blk_notify(void *vdev, struct virtio_vq_info *vq) static int virtio_blk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts) { - char bident[sizeof("XX:X:X")]; + char bident[16]; struct blockif_ctxt *bctxt; MD5_CTX mdctx; u_char digest[16];